Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this is from a userform code connected to one workbook. the code then
opens a 2nd workbook & selects a certain sheet based on what month it is. then i have to switch back & forth between the 2 workbooks..... i can qualify the sheet i need in the workbook that the userform is in, but for some reason it won't let me qualify the sheet in the OTHER workbook, even tho i've identified the workbook, etc. any ideas? xxxxxxxxxxxxxxxxxxxxx Sub cmdExport_click() Me.Hide myFileName = ThisWorkbook.Name myPath = ThisWorkbook.Path mySheet = Workbooks(myFileName).ActiveSheet.Name 'this works fine Workbooks.Open Filename:="\\Server\users\Susan\My Documents\Miscellaneous\Excel Help\Macro Projects-Excel\RPC Book1.xls" myRPC = ActiveWorkbook.Name 'this works fine 'open the correct worksheet by month Call MonthNumber Call Select_Sheet myRPCSheet = Workbooks(myRPC).ActiveSheet.Name '****this is where it bombs.... 'switch back to the invoice workbook Workbooks(myFileName).Activate end sub xxxxxxxxxxxxxxxxx i hate to use "activeworkbook" to qualify that 2nd sheet, even though the correct one IS active at that point; i wanted to use the actual workbook name. the error i get is "run-time error 91 - object variable or with block variable not set". thanks for any help. susan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Visual Basic - Variable Sheet Names | Excel Discussion (Misc queries) | |||
Using Sheet names & Workbook names in VBA coding | Excel Programming | |||
Working with first and last names | Excel Worksheet Functions | |||
return all worksheet tab names and chart sheet tab names in report - an example | Excel Programming | |||
Variable names in SQL | Excel Programming |