Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro - New Workbook
I have a macro that opens a new workbook and creates 120 tabs of information,
everything process correctly works perfectly only when run for the first time. The issue is when i run the macro again, Excel now opens "book2" The macro then stops as it is set for Book 1. Can this variable be adjusted for Cells.Select Selection.Copy Windows("book1").Activate This is where it runs all the subsequent part of the macro from. The macro before this opens up a new work book with the tab settings then it grabs the required info and copies it and then goes to the workbook. Please help Cheers |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro - New Workbook
hi Goaliemenace Here are two examples of how you can set a variable to be a workbook. The first is when you open an existing file & the second is if you are create a file... VBA Code: -------------------- Option Explicit Sub Macro2() Dim Createdwb As Workbook Set Createdwb = Workbooks.Open(Filename:="blah.xls") 'or Set Createdwb = Workbooks.Add 'other code, eg... Createdwb.activate 'free memory Set Createdwb = Nothing End Sub -------------------- hth Rob -- broro183 Rob Brockett. Always learning & the best way to learn is to experience... ------------------------------------------------------------------------ broro183's Profile: 333 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=180996 Microsoft Office Help |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro - New Workbook
The latter worked perfectly.
Really appreciate your help Cheers "broro183" wrote: hi Goaliemenace Here are two examples of how you can set a variable to be a workbook. The first is when you open an existing file & the second is if you are create a file... VBA Code: -------------------- Option Explicit Sub Macro2() Dim Createdwb As Workbook Set Createdwb = Workbooks.Open(Filename:="blah.xls") 'or Set Createdwb = Workbooks.Add 'other code, eg... Createdwb.activate 'free memory Set Createdwb = Nothing End Sub -------------------- hth Rob -- broro183 Rob Brockett. Always learning & the best way to learn is to experience... ------------------------------------------------------------------------ broro183's Profile: 333 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=180996 Microsoft Office Help . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro - New Workbook
Thanks for the feedback - I'm pleased I could help :-) Rob -- broro183 Rob Brockett. Always learning & the best way to learn is to experience... ------------------------------------------------------------------------ broro183's Profile: 333 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=180996 Microsoft Office Help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
saving macro from workbook to Personal Macro Workbook | Excel Discussion (Misc queries) | |||
Macro to copy specific data from master workbook to another workbook | Excel Programming | |||
How do I call up a line of code that references a cell/range in theactive workbook workbook where I am running my macro from? | Excel Programming | |||
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? | Excel Programming | |||
Excel Gurus = want a macro in 1 workbook to get info from another workbook = Read please | Excel Programming |