I am trying to use Union for the first time and I guess I am not getting it as the Macros fires but nothing happens
Union(Range("A2:D" & LR), Range("K2:Q" & LR)).SpecialCells(xlCellTypeVisible).Copy _
Destination:=ws.[A1].Offset(lRow, 0)
Thanks
Sub TestXXX()
Dim ws As Worksheet
Dim lCol As Long
Dim lRow As Long
Dim LR As Long
Set ws = ThisWorkbook.Sheets("XXX")
lCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
lRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
With ws
'lRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
.AutoFilterMode = False
.Range("A1", Cells(lRow, lCol)).Cells.AutoFilter
.Range("A1", Cells(lRow, lCol)).Cells.AutoFilter Field:=11, Criteria1:="Yes"
LR = Range("A" & Rows.Count).SpecialCells(xlCellTypeVisible).End(xlUp).Row
Union(Range("A2:D" & LR), Range("K2:Q" & LR)).SpecialCells(xlCellTypeVisible).Copy _
Destination:=ws.[A1].Offset(lRow, 0)
.AutoFilterMode = False
Columns("K:Q").Delete
End With
Else: Columns("K:Q").Delete
End If
End Sub
Bookmarks