Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, 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.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Vb Help

  • Please log in to reply
1 reply to this topic

#1 Aggie1995


  • Members
  • 34 posts
  • Local time:05:55 AM

Posted 28 April 2008 - 03:10 PM

I am new to VB and am running into trouble when trying to record a macro in Excel.

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

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.


BC AdBot (Login to Remove)



#2 adh_amit


  • Members
  • 20 posts
  • Local time:04:25 PM

Posted 12 May 2008 - 01:41 AM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users