run macro in selected column

CAV124

New Member
Joined
Apr 5, 2012
Messages
3
I have a macro that copies and paste data from worksheet into specific cells in another worksheet. I run this several times a week and I currently have a separate macro for each column I want the data copies too.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
How can I make one Macro that will run and populated in whatever column I have selected? <o:p></o:p>
<o:p> </o:p>
Example: Day 1 I want to copy data cells A1..A5 on Tab 1 and populate cells C1..C5 in Tab 2 but next day want to do same thing but populate in cells D1..D5 and so on. <o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
 
Hi.

Code:
Sub CopyMacro1()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
ws1.Range("A1:A5").Copy ws2.Cells(1, ws2.Cells _
(1, Columns.Count).End(xlToLeft).Column + 1)
End Sub
 
Upvote 0

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