Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move activesheet from one workbook to another in excel 2

Status
Not open for further replies.

gumby2

Programmer
May 12, 2003
3
US
I have a macro that that when ran, opens another workbook and moves the active worksheet from the first open workbook to the one that the macro opens.
 
Well I should say that is what I want it to do. I can get the 2nd workbook to open but am having trouble with the code to get the active sheet to move from 1st book to 2nd book.
 
This sounds like a homework exercise.

Here's a tip anyway: Use the macro recorder.

 
Try recoding it on the macro recorder
To use the copy sheet functionality
Start Macro Recorder
Right click on the sheet you want to copy
Choose "Move Or Copy"
Tick Copy
Select the workbook you want to copy it to from the dropdown list (it must be already open)
Select the position you want it to be in from the list of worksheets
Select ok
Turn off macro recorder
et voila

Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
First of all I am new at this. 2nd this is not a home work exercise but thanks for the tip anyway. I have used the recorder as you have described. Problem is: I will be adding many new sheets so that is why I want to move only the active sheet. When using the recorder it uses the sheet name of the sheet used for recording. Any help would be much appreciated.
 
Hi
Code:
ActiveSheet.Move before:=Workbooks("Book2").Sheets(1)
is the line you want.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
[blue]
Code:
Sub test()
  MsgBox ActiveSheet.Name
End Sub
[/blue]


This is really too simple. Did you try anything before posting here? E.g., look at the help file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top