Hi Guys, I need help witth regards to this. I've tried this with just 1 column only. But now, I have to copy and paste multiple columns.
Public Sub RunMe()
Dim i As Long
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim strFile1, strFile2 As String
Dim strCol1, strCol2
strCol1 = ActiveSheet.Cells(9, 4)
strCol2 = ActiveSheet.Cells(10, 4)
strFile1 = ActiveSheet.Cells(3, 5)
strFile2 = ActiveSheet.Cells(5, 5)
Set WB1 = Application.Workbooks.Open(strFile1)
Set WB2 = Application.Workbooks.Open(strFile2)
WB1.Activate
For i = 1 To WB1.Sheets.Count
If WB1.Sheets(i).Name <> "Sheet1" Then
WB2.Sheets(WB1.Sheets(i).Name).Activate
'WB2.Sheets(WB1.Sheets(i).Name).Range(strCol2).EntireColumn.Select
'Selection.MergeCells = False
WB2.Sheets(WB1.Sheets(i).Name).Range(strCol2).EntireColumn.Select
Selection.Copy
WB1.Sheets(i).Activate
WB1.Sheets(i).Range(strCol1).Select
'Selection.MergeCells = False
Selection.PasteSpecial xlPasteAll
End If
Next i
MsgBox "Done!"
End Sub
GIVEN THAT NOW, I NEED MULTIPLE COLUMNS TO BE SELECTED AND PASTE.
WB2 Copy Columns
H1, I1, J1, K1, L1, M1, P1, Q1, N1, O1, R1, S1, X1, W1, C1, B1, AC1, A1, U1, AB
WB1 Paste Columns to
A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1, O1, Q1, R1, S1, Y1, AC1, AD1, AG1
THANKS IN ADVANCE!
Public Sub RunMe()
Dim i As Long
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim strFile1, strFile2 As String
Dim strCol1, strCol2
strCol1 = ActiveSheet.Cells(9, 4)
strCol2 = ActiveSheet.Cells(10, 4)
strFile1 = ActiveSheet.Cells(3, 5)
strFile2 = ActiveSheet.Cells(5, 5)
Set WB1 = Application.Workbooks.Open(strFile1)
Set WB2 = Application.Workbooks.Open(strFile2)
WB1.Activate
For i = 1 To WB1.Sheets.Count
If WB1.Sheets(i).Name <> "Sheet1" Then
WB2.Sheets(WB1.Sheets(i).Name).Activate
'WB2.Sheets(WB1.Sheets(i).Name).Range(strCol2).EntireColumn.Select
'Selection.MergeCells = False
WB2.Sheets(WB1.Sheets(i).Name).Range(strCol2).EntireColumn.Select
Selection.Copy
WB1.Sheets(i).Activate
WB1.Sheets(i).Range(strCol1).Select
'Selection.MergeCells = False
Selection.PasteSpecial xlPasteAll
End If
Next i
MsgBox "Done!"
End Sub
GIVEN THAT NOW, I NEED MULTIPLE COLUMNS TO BE SELECTED AND PASTE.
WB2 Copy Columns
H1, I1, J1, K1, L1, M1, P1, Q1, N1, O1, R1, S1, X1, W1, C1, B1, AC1, A1, U1, AB
WB1 Paste Columns to
A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1, O1, Q1, R1, S1, Y1, AC1, AD1, AG1
THANKS IN ADVANCE!
