Samuel Cole
Samuel Cole

Reputation: 11

Last Row VBA Error - Returning value as 1?

Hi All i have the below code within a macro but for some reason it keeps returning the last row as 1 even though it isnt the last row, any thoughts?

lr1 = Sheets("SAPExport").Cells(Rows.Count, "AZ").End(xlUp).Row

Sheets("SAPExport").Range("AZ1:BB" & lr1).AutoFilter Field:=3, Criteria1:=cell.Value
Sheets("SAPExport").Range("AZ1:BB" & lr1).AutoFilter Field:=1, Criteria1:=("Y")

lr = Sheets("SAPExport").Cells(Rows.Count, "AZ").End(xlUp).Row

Upvotes: 0

Views: 487

Answers (1)

JMB
JMB

Reputation: 61

Not sure about the "AZ" range. I guess the goal is to have the latest row of multiple columns ?

If so, try :

lr = Sheets("SAPExport").Columns("A:Z").Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)

Upvotes: 1

Related Questions