Copy multiple columns to new wb and different columns

mcfluffy

New Member
Joined
Oct 28, 2013
Messages
15
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! :)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,216,303
Messages
6,129,983
Members
449,549
Latest member
birdguy_1930

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top