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

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
 
J

Joel

Try this instead

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top