Hello,
I’m trying to copy some filtered rows (including the criterie “blank”) from several sheets to one sheet only but when the last row have the criteria BLANK the row is not copied.
The code that I’m using is:
————————————————————————————-
‘Cycle through worksheets
With Worksheets(“MKT”)
For i = 1 To Worksheets.Count
Worksheets(i).Unprotect Password:=”1″
If Worksheets(i).Name “MKT” Then
Worksheets(i).Activate
‘Filter Sheets and copy rows to MKT
Worksheets(i).Range(“B7:L7”).AutoFilter Field:=9, Criteria1:=Array( _
“Opt1”, “Opt2”, “=”), Operator:=xlFilterValues
LastRow = ActiveSheet.Cells(Rows.Count, 10).End(xlUp).Row
For Each targetrow In Worksheets(i).Range(“B8:L” & LastRow).Rows
If targetrow.Hidden = False Then
For J = 2 To 11
.Cells(sourcerow, J – 1) = Cells(targetrow.Row, J)
Next J
sourcerow = sourcerow + 1
End If
Next targetrow
‘Protect Sheets
Worksheets(i).Protect Password:=”1″, AllowFiltering:=True
End If
Next i
End With
————————————————————————————-
What I’m doing wrong?
Many thanks for any help
LL