Excel FileName as variable in macro?

Joined
Sep 13, 2005
Messages
1
Reaction score
0
Is there any way I can use some generic variable FileName, entered by the user or (preferably) passed in as whatever the current filename is, to make a macro run dynamically? The macro goes between two files, taking information out of one and pasting the values into another. The only problem is that the starting filename will not be the same each time.

Below is the code I have and the second to last line shows where I would need to pass in whatever the current filename is.

'Open Output File and clear out the contents
Workbooks.Open Filename:="\\DRFSFILP3\Groups$\PMODEL\OutputForFieldSales.xls"
Windows("OutputForFieldSales.xls").Activate
ActiveWindow.WindowState = xlMaximized
Sheets("Summary1").Select
Cells.Select
Selection.Delete Shift:=xlUp
range("A1").Select
ActiveSheet.Next.Select
Cells.Select
Selection.Delete Shift:=xlUp
range("A1").Select
ActiveSheet.Previous.Select
range("A1").Select


'Copy the main summary page from New Deal Model
Windows("thisFileName").Activate
Sheets("Summary").Select

Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top