Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a master wookbook that need to update weekly. The new information
comes from a file that sent to me every week(the name of the file changes to
reflect the updated date). I want to use macro to automate this process.
Everything work out fine but I don't know how to change the file name in
macro.

Any advice is highly appreciated.

Jason
 
You could store the file name in a cell in the macro workbook, and
change or recalculate it as required. For example:

Sub OpenMyFile()
Dim strFilePath As String
Dim strFileName As String

strFilePath = "c:\Data\"
strFileName = Worksheets("Sheet1").Range("A1").Value

Workbooks.Open strFilePath & strFileName

End Sub
 
Thanks a lot, Debra.

Jason

Debra Dalgleish said:
You could store the file name in a cell in the macro workbook, and
change or recalculate it as required. For example:

Sub OpenMyFile()
Dim strFilePath As String
Dim strFileName As String

strFilePath = "c:\Data\"
strFileName = Worksheets("Sheet1").Range("A1").Value

Workbooks.Open strFilePath & strFileName

End Sub
 

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

Similar Threads


Back
Top