Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default variable sheet names not working

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic - Variable Sheet Names MarkT Excel Discussion (Misc queries) 10 December 18th 07 07:12 PM
Using Sheet names & Workbook names in VBA coding Colin Foster[_5_] Excel Programming 5 July 7th 06 07:04 PM
Working with first and last names David Bateman Excel Worksheet Functions 3 February 20th 06 01:54 AM
return all worksheet tab names and chart sheet tab names in report - an example DataFreakFromUtah Excel Programming 2 October 6th 04 08:09 PM
Variable names in SQL Hall Excel Programming 2 May 28th 04 11:39 PM


All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"