Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro question | Excel Worksheet Functions | |||
How to stop Excel remembering/loading macro from previously opened Workbook | Excel Discussion (Misc queries) | |||
Compiling macro based on cell values | Excel Discussion (Misc queries) | |||
write a macro for variable cells | Excel Discussion (Misc queries) | |||
Search, Copy, Paste Macro in Excel | Excel Worksheet Functions |