I need help on macros in Excel. I have a table in Excel (example attached).
I need columns A, E and G from source sheet, after last row i need A,E and H , after last row A,E and I and so on. Means Column A and E will be constant, only third column will change until column K. In vertical manner.
Source data:
A B C D E F G H I J K NAME AGE CITY STATE COUNTRY CODE PART DUEDATE VEND COMM QTY
Target:
A E G A E H A E I A E J A E K
EDIT: Code I am trying:
Sub Mosaic()
With ws
'Get the last row and last column
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
With ws2
'Get the last row and last column
lRow2 = .Range("A" & .Rows.Count).End(xlUp).Row
lCol2 = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
'Save the range from A1:Alastrow and E1:Elastrow and store as variable
Set aRng = ws.Range("A1" & lRow)
Set aRng2 = ws.Range("E1" & lRow)
'Union(AE range and G1:Glastrow)
Set gRng = ws.Range("G1" & lRow)
Set hRng = ws.Range("H1" & lRow)
Set uRng = Union(aRng, aRng2, gRng)
uRng.Copy
ws2.Range("A" & lRow2).PasteSpecial
End Sub