#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Variable Macro

I am trying to create a macro with a file name variable. The code I have
written doesn't seem to work, any ideas!

Dim ImportDir As String
Dim ImportFile As String

ImportDir = Range("a17").Value
ImportFile = Range("b17").Value

Windows("ImportFile").Activate
Sheets("Top 10 month").Select
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Variable Macro

Hi, Heather-
Instead of this line:
Windows("ImportFile").Activate

....try this:
Windows(ImportFile & ".xls").Activate

Did you post the entire macro? What are you trying to do? There may
be additional code involved if you're trying to specify a location and
filename to open.

Dave O

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Variable Macro

Oops- just realized: if the value in B17 already includes the .xls
along with the filename, then try removing the quotes. It may be just
changing
Windows("ImportFile").Activate
to this:
Windows(ImportFile).Activate

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 question Chris Excel Worksheet Functions 12 July 7th 06 01:23 AM
How to stop Excel remembering/loading macro from previously opened Workbook Norman Yuan Excel Discussion (Misc queries) 4 June 17th 06 04:13 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
write a macro for variable cells Garry Excel Discussion (Misc queries) 0 March 22nd 06 07:45 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM


All times are GMT +1. The time now is 07:42 AM.

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"