forums Computer Tutorials Computer Help and Spyware Removal File DatabaseUninstall Database Windows Startup Programs Database Computer Resources Computer Glossary Forums Computer Help and Spyware Removal
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
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.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

 
Reply to this topicStart new topic
> Vb Help, copying information from one MS Excel sheet to other sheets
Aggie1995
post Apr 28 2008, 03:10 PM
Post #1


New Member
*

Group: Members
Posts: 10
Joined: 17-February 08
Member No.: 190,752



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
'

'
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...
Go to the top of the page
 
+Quote Post
adh_amit
post 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.

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 6th July 2008 - 01:01 PM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Malware Removal Guides

© 2003-2008 All Rights Reserved Bleeping Computer LLC.