ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error 91: Object Variable or With block variable not set (https://www.excelbanter.com/excel-programming/432529-run-time-error-91-object-variable-block-variable-not-set.html)

Ayo

Run-time error 91: Object Variable or With block variable not set
 
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

joel

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

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

"Ayo" wrote:

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



All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com