Hi! I'm trying to write code that will filter column J in a spreadsheet for "abc" and "def" and move the rows containing either to a different worksheet (wsOut). The code below works for "ABC" but I haven't found a way to modify the part in blue that works.
m = wbSource.Range("J" & wbSource.Rows.Count).End(xlUp).Row
On Error Resume Next
wbSource.Range("A1:K1").AutoFilter Field:=10, Criteria1:="ABC*"
With wbSource.Range("J2:J" & m).SpecialCells(xlCellTypeVisible).EntireRow
.Copy Destination:=wsOut.Range("A" & Rows.Count).End(xlUp).Offset(1)
.Delete
End With
For Each ws In Worksheets ' Clear all filters
If ws.AutoFilterMode = True Then
Debug.Print ws.Name
ws.AutoFilterMode = False
End If
Next
My next step is hopefully going to be multiple filters in multiple columns so any help with that would be appreciated. My end goal is to sort all of my data into buckets but I'm still figuring out what the rules are (new job, still training. My predecessor did this line by line which is crazy).
Thanks in advance. Let me know if more information is needed.
m = wbSource.Range("J" & wbSource.Rows.Count).End(xlUp).Row
On Error Resume Next
wbSource.Range("A1:K1").AutoFilter Field:=10, Criteria1:="ABC*"
With wbSource.Range("J2:J" & m).SpecialCells(xlCellTypeVisible).EntireRow
.Copy Destination:=wsOut.Range("A" & Rows.Count).End(xlUp).Offset(1)
.Delete
End With
For Each ws In Worksheets ' Clear all filters
If ws.AutoFilterMode = True Then
Debug.Print ws.Name
ws.AutoFilterMode = False
End If
Next
My next step is hopefully going to be multiple filters in multiple columns so any help with that would be appreciated. My end goal is to sort all of my data into buckets but I'm still figuring out what the rules are (new job, still training. My predecessor did this line by line which is crazy).
Thanks in advance. Let me know if more information is needed.