I have a dataset where I want to the VBA to do an auto-filter and in column B just unselect 0 and keep all the other values.
Then copy the visible cells to a new sheet. Can someone help me what the error is
Thanks
Sub findlastrowwithvaluefilter()
ActiveWorkbook.Sheets("CASCADE -Offshore Upload Format").Activate
LastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
With Range("A1:Q" & LastRow)
.AutoFilter
.AutoFilter Field:=2, Criteria1:="Select All", Operator:=xlAnd, Criteria1:="<>0"
End With
Range("A2:Q" & LastRow).Select
ActiveSheet.Range("A1:Q1" & LastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
MsgBox (LastRow)
End Sub
Replace
with
and should work