Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Nigel
 
Posts: n/a
Default Workbook name as variable to another workbook


Hi,

Can you save a specific workbook name as a variable, to be used in a
different macro? i need the variable to be saved and available to return to
the specific workbook open if i have a lot of books open to complete the task.

Regards,

nigel

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Option Explicit
Dim myWkbkName As String
Sub runmefirst()
myWkbkName = ThisWorkbook.Name
End Sub
Sub runmesecond()
MsgBox myWkbkName
End Sub

If you execute runmefirst first, then runmesecond, you'll see that myWkbkname is
available in the second.

If you need to put the routines in different modules, declare myWkbkName as
Public:
Public myWkbkName As String




Nigel wrote:

Hi,

Can you save a specific workbook name as a variable, to be used in a
different macro? i need the variable to be saved and available to return to
the specific workbook open if i have a lot of books open to complete the task.

Regards,

nigel


--

Dave Peterson
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
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
make hidden window or workbook visible without specify the name mango Excel Worksheet Functions 1 December 30th 04 03:05 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 04:46 PM.

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"