Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can a Macro use Different File Names?

I am trying to create a macro that goes across 2 spreadsheets, the name of
the first spreadsheet will remane consistent but the second spreadsheet will
have a randomly generated name. I created a macro that runs the functions
that I need but only if the second spreadsheet name doesn't change, once it
changes I get errors.

Is there a way to create a macro like this?

Thank you in advance for your help.

-Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Can a Macro use Different File Names?


Assume there are only two visible workbooks (spreadsheets)
Dim bk as Workbook, bk1 as Workbook, bk2 as Workbook
for each bk in Workbooks
if bk.Windows(1).Visible then
if lcase(bk.name) < "constant.xls" then
sName = bk.name
exit sub
end if
end if
Next

set bk2 = workbooks(sname)
set bk1 = workbooks("constant.xls")

Obviously change constant.xls to the name (in lowercase) of the fixed name
workbook

If you meant sheets in the same workbook, then just use worksheet/worksheets
instead of workbook/workbooks

--
Regards,
Tom Ogilvy
"markmidwest" wrote:

I am trying to create a macro that goes across 2 spreadsheets, the name of
the first spreadsheet will remane consistent but the second spreadsheet will
have a randomly generated name. I created a macro that runs the functions
that I need but only if the second spreadsheet name doesn't change, once it
changes I get errors.

Is there a way to create a macro like this?

Thank you in advance for your help.

-Mark

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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
File Names within a Macro Function John Excel Worksheet Functions 2 December 5th 08 07:11 PM
Macro File Names John Excel Worksheet Functions 2 December 5th 08 06:27 AM
Macro File Names John Excel Worksheet Functions 1 December 5th 08 06:23 AM
VBA macro to obtain file names using WIN32 API Mudd[_2_] Excel Programming 3 September 5th 04 12:17 AM


All times are GMT +1. The time now is 10:24 PM.

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

About Us

"It's about Microsoft Excel"