ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date (https://www.excelbanter.com/excel-discussion-misc-queries/24176-date.html)

Jason

Date
 
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

Debra Dalgleish

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


Jason wrote:
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



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


Jason

Thanks a lot, Debra.

Jason

"Debra Dalgleish" wrote:

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


Jason wrote:
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



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html




All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com