Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Syntax to define a variable for current file

Can someone tell me how to define a variable to hold the name of the current
file so that later I can reactivate the file by referring to the variable
rather hard code its name?

Thanks - It escapes me !


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Syntax to define a variable for current file

Mervyn,

Try something like

Dim FName As String
FName = ActiveWorkbook.Name
' more code here
Workbooks(FName).Activate


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Mervyn Thomas" wrote in message
...
Can someone tell me how to define a variable to hold the name

of the current
file so that later I can reactivate the file by referring to

the variable
rather hard code its name?

Thanks - It escapes me !




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Syntax to define a variable for current file

dim myWkbk as workbook
set mywkbk = activeworkbook
'''do lots of stuff
mywkbk.activate

But lots of times you don't even have to activate it to work with it.

mywkbk.worksheets("sheet1").range("B37").value = "Hi there"

would assign a text value to B37 in sheet1 of that workbook.

Mervyn Thomas wrote:

Can someone tell me how to define a variable to hold the name of the current
file so that later I can reactivate the file by referring to the variable
rather hard code its name?

Thanks - It escapes me !


--

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
Define variable range input for SUM() function JeffC Excel Worksheet Functions 4 May 16th 09 03:54 AM
Define Variable Name using VBA GTReferee Excel Discussion (Misc queries) 2 January 21st 09 06:37 PM
Using a Variable to Define Series Posse John Charts and Charting in Excel 2 August 30th 06 01:18 PM
How to take the worksheet name as a variable(Label/Define) in a fo Subin Excel Worksheet Functions 2 March 14th 06 12:43 PM
Macro syntax to open file in current explorer folder [email protected] Excel Discussion (Misc queries) 4 January 11th 06 12:07 PM


All times are GMT +1. The time now is 10:22 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"