Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.![]() ![]() |
Apr 28 2008, 03:10 PM
Post
#1
|
|
|
New Member ![]() Group: Members Posts: 10 Joined: 17-February 08 Member No.: 190,752 |
I would like to copy a column from one sheet and run the macro in multiple sheets to have it paste this information. I recorded a simple macro to illustrate: Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/28/2008 by PREWITRO ' ' Sheets("Sheet1").Select Columns("A:A").Select Selection.Copy Sheets("Sheet2").Select Columns("A:A").Select ActiveSheet.Paste End Sub The problem is, when I now go to sheet 3 and run this macro, it copies the data from sheet1 and then jumps to sheet2. The data is never pasted into sheet 3. Is there any way to write code to pick the sheet that you started running the macro from? Any suggestions would be appreciated. Thanks... |
|
|
|
May 12 2008, 01:41 AM
Post
#2
|
|
|
Member ![]() ![]() Group: Members Posts: 20 Joined: 8-January 06 Member No.: 49,633 |
try the following:
Sub Macro1() ' ActiveWorkbook.Worksheets("Sheet1").Columns("A:A").Copy Destination:=ActiveWorkbook.Worksheets("sheet2").Columns("A:A") End Sub This will paste data from column A from sheet 1 to column A of sheet 2 If you want to copy paste same column A from Sheet 1 to mulitple sheets, you can put this statment in loop.But then, you will have to save the name of the new sheet in some variable and substitute it to sheet 2 in my example. |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 6th July 2008 - 01:01 PM |