copy and paste macro

k_babb

Board Regular
Joined
Mar 28, 2011
Messages
71
Could some please help with a macro that asks the user for a column to copy then asks for where is should be pasted

the copy will be from sheet one and the paste will be on sheet 2

thank you
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try

Code:
Sub atest()
Dim s As String, X
s = InputBox("Enter From and To column letters separated by comma, e.g. H,A")
X = Split(s, ",")
Sheets("Sheet1").Columns(LBound(X)).Copy Destination:=Sheets("Sheet2").Range(X(UBound(X)) & 1)
End Sub
 
Upvote 0
Excellent thanks for that!! just wondering going one step further is the a way to as the user for the columns then paste them into sheet 2 in order
so say i want to copy A,C,D,E,AA from sheet one into sheet 2 just starting at column A so A,B,C,D,E is there away to do that
 
Upvote 0
i have about 20 columns on 30 workbooks i need to be able to copy to sheet 2 then i will be putting in to a new workbook
 
Upvote 0
Maybe like this

Code:
Sub btest()
Dim s As String, i As Long, X
s = InputBox("Enter From column letters separated by comma, e.g. A,C,AA")
X = Split(s, ",")
For i = LBound(X) To UBound(X)
    Sheets("Sheet1").Columns(X(i)).Copy Destination:=Sheets("Sheet2").Cells(1, i + 1)
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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