PDA

View Full Version : VBA transfer columns from two reference sheets to a master sheet with different colum



Simple_Man
08-26-2016, 09:11 AM
Hello:

Looking for code to transfer columns from two reference sheets to a master sheet with different columns ranges.

Two reference sheets "Tracker" & " Archive" have columns A:U first row headers
Master sheet columns A:Z

Need code to transfer columns A:E from reference sheets to B:F on Master sheet
Need to transfer columns F:U from reference sheets to K:Z on Master sheet

Unable to find similar code in threads

Can some one help?

Thank you :)

jolivanes
08-28-2016, 10:22 PM
If I understand your requirement right, you could try this

Sub Maybe()
Dim shArr, i As Long
shArr = Array("Tracker", "Archive")
For i = LBound(shArr) To UBound(shArr)
With Sheets(shArr(i))
.Range("A2:E" & .Cells(.Rows.Count, 1).End(xlUp).Row).Resize(, 5).Copy Sheets("Master").Cells(Rows.Count, 2).End(xlUp).Offset(1)
.Range("F2:U" & .Cells(.Rows.Count, 6).End(xlUp).Row).Resize(, 16).Copy Sheets("Master").Cells(Rows.Count, 11).End(xlUp).Offset(1)
End With
Next i
End Sub


I assumed that the space in front of the word Archive is a slip of the typing finger!!!

Simple_Man
08-29-2016, 09:32 AM
Thank you. The code you provided worked. :)