Run-time error 91: Object Variable or With block variable not set

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

Can someone help me out with this error. I can't figure out what it means and
what the problem is in the code. pastdueWSlastRow=279

ActiveWorkbook.Worksheets("PAST DUE SITES").AutoFilter.Sort.SortFields.Add
Key _
:=Range("A3:A" & pastdueWSlastRow), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
 
Try this instead

With ActiveWorkbook.Worksheets("PAST DUE SITES")
.Cells.AutoFilter
.Rows("3:" & pastdueWSlastRow).Sort _
header:=xlNo, _
Key:=Range("A3"), _
Order:=xlAscending
End With
 
Back
Top