Hi all,
I am new to using VBA and new here as well with my first post, but hoping someone can help solve an issue I'm running into. Please forgive any omission errors and explanation shortfall.
In a worksheet, I am pulling data in from an outside source into columns I:M (with varying lengths(rows) of data), then using xlookup formulas to populate values into N:O all with headers on Row 1. I am initially filtering column J to eliminate any zero values, then want to filter column O only if the value of "*UpdateMasterList" value exists in that column. If it does exist, then the filter should be applied and I want to copy all of the filtered data from A1:O and paste values into a new sheet. If that value doesn't exist, the code should jump to the next step.
Here is my code for these steps. However, it just jumps over the filtering for "*UpdateMasterList" and copies everything to the new sheet.
I am new to using VBA and new here as well with my first post, but hoping someone can help solve an issue I'm running into. Please forgive any omission errors and explanation shortfall.
In a worksheet, I am pulling data in from an outside source into columns I:M (with varying lengths(rows) of data), then using xlookup formulas to populate values into N:O all with headers on Row 1. I am initially filtering column J to eliminate any zero values, then want to filter column O only if the value of "*UpdateMasterList" value exists in that column. If it does exist, then the filter should be applied and I want to copy all of the filtered data from A1:O and paste values into a new sheet. If that value doesn't exist, the code should jump to the next step.
Here is my code for these steps. However, it just jumps over the filtering for "*UpdateMasterList" and copies everything to the new sheet.
VBA Code:
Sheets("Test").Select
Columns("I:O").Select
Selection.AutoFilter
Range("O2").Select
ActiveSheet.Range("$I$1:$O$570").AutoFilter Field:=2, Criteria1:="<>0", _
Operator:=xlAnd
If Range("O2" & LastRow).Value = "*UpdateMasterList" Then
ActiveSheet.Range("$I$1:$O$570").AutoFilter Field:=7, Criteria1:="*UpdateMasterList"
Cells.Select
Range("I2:O" & LastRow).Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Else
End If