View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 18
Default Dynamic filename

How about if I have two worksheets open and the macro is
selecting between the two worksheets. This will work
fine if I only have one worksheet open, but if I have two
I would have to refer to the spreadsheet by name to avoid
confusion. I'm trying to use this spreadsheet as a
template for users that don't know VBA code so automation
is key.

Thanks for the tip.
JC
-----Original Message-----
JC,

It depends on what workbook you want to reference. If

you want
the workbook that is presently active, use

mystring = ActiveWorkbook.Sheets("WorkOrders").Range

("I2").Value


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


"JC" wrote in

message
...
mystring = Workbooks("SupportTemplate.xls").Sheets
("WorkOrders").Range("I2").Value
In the above code, is there a way to make the filename

of
the spreadsheet (SupportTemplate.xls) link dynamically

to
the name of the spreadsheet. Thus, if the spreadsheet
name changes, the reference in the code changes as

well.

Thanks,



.