I am trying to run a macro by clicking in a cell A10. Getting Run-time error '1004': Select method of Range class failed.
"debug" highlights the 4th line down:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("A10"), Target) Is Nothing Then
Sheets("OT Requests & Hours").Select
**Range("B5:AA22").Select**
ActiveWorkbook.Worksheets("OT Requests & Hours").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("OT Requests & Hours").Sort.SortFields.Add2 Key:= _
    Range("C5:C22"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
    :=xlSortNormal
ActiveWorkbook.Worksheets("OT Requests & Hours").Sort.SortFields.Add2 Key:= _
    Range("Z5:Z22"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
    xlSortNormal
ActiveWorkbook.Worksheets("OT Requests & Hours").Sort.SortFields.Add2 Key:=
    Range ("AA5:AA22"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
    :=xlSortNormal
With ActiveWorkbook.Worksheets("OT Requests & Hours").Sort
    .SetRange Range("B5:AA22")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With
Sheets("Sun").Select
Range("A10").Select
ActiveCell.FormulaR1C1 = _
    "=IF(AND(R[2]C[4]=""OT"",'OT Requests & Hours'!R[-5]C[2]=""Mid""),'OT Requests & Hours'!R[-5]C[1],"""")"
Range("A11").Select
End If
End Sub
 
     
    