Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Open workbooks - filenames change daily

I have a user who needs to open five workbooks every morning. These workbooks
are named with yesterday's date and then an alpha identifier (e.g. 111605SL).
This means that the filename changes daily and not always to the previous
date (e.g. today he opens yesterday's, tomorrow he opens today's, on Monday
he will open Friday's).

Is it even possible to write a macro to open these workbooks?

Your help is appreciated.
--
Thanks,
GillianHG
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Open workbooks - filenames change daily

Gillian,

Try the macro below. Change the path to reflect the folder path where the files are stored, and
change the alpha codes for each of the five files.

Note that this won't automatically account for holidays like it accounts for weekends.

HTH,
Bernie
MS Excel MVP

Sub OpenFilesByDateCode()
Dim myDateCode As String
Dim myPath As String

myPath = "C:\Folder1Name\Folder2Name\"

myDateCode = Format(Date - IIf(Date Mod 7 = 2, 3, 1), "mmddyy")

If MsgBox("Open files from DateCode " & _
myDateCode & "?", vbYesNo) = vbYes Then
Workbooks.Open myPath & myDateCode & "CL.xls"
Workbooks.Open myPath & myDateCode & "AB.xls"
Workbooks.Open myPath & myDateCode & "CD.xls"
Workbooks.Open myPath & myDateCode & "EF.xls"
Workbooks.Open myPath & myDateCode & "GH.xls"
End If
End Sub





"GillianHG" wrote in message
...
I have a user who needs to open five workbooks every morning. These workbooks
are named with yesterday's date and then an alpha identifier (e.g. 111605SL).
This means that the filename changes daily and not always to the previous
date (e.g. today he opens yesterday's, tomorrow he opens today's, on Monday
he will open Friday's).

Is it even possible to write a macro to open these workbooks?

Your help is appreciated.
--
Thanks,
GillianHG



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Open workbooks - filenames change daily

Thanks Bernie I'll give it a try!
--
Thanks,
GillianHG


"Bernie Deitrick" wrote:

Gillian,

Try the macro below. Change the path to reflect the folder path where the files are stored, and
change the alpha codes for each of the five files.

Note that this won't automatically account for holidays like it accounts for weekends.

HTH,
Bernie
MS Excel MVP

Sub OpenFilesByDateCode()
Dim myDateCode As String
Dim myPath As String

myPath = "C:\Folder1Name\Folder2Name\"

myDateCode = Format(Date - IIf(Date Mod 7 = 2, 3, 1), "mmddyy")

If MsgBox("Open files from DateCode " & _
myDateCode & "?", vbYesNo) = vbYes Then
Workbooks.Open myPath & myDateCode & "CL.xls"
Workbooks.Open myPath & myDateCode & "AB.xls"
Workbooks.Open myPath & myDateCode & "CD.xls"
Workbooks.Open myPath & myDateCode & "EF.xls"
Workbooks.Open myPath & myDateCode & "GH.xls"
End If
End Sub





"GillianHG" wrote in message
...
I have a user who needs to open five workbooks every morning. These workbooks
are named with yesterday's date and then an alpha identifier (e.g. 111605SL).
This means that the filename changes daily and not always to the previous
date (e.g. today he opens yesterday's, tomorrow he opens today's, on Monday
he will open Friday's).

Is it even possible to write a macro to open these workbooks?

Your help is appreciated.
--
Thanks,
GillianHG




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
Linking to Workbooks that Change Name Daily pwk Excel Worksheet Functions 3 January 10th 07 10:12 PM
Linking to Workbooks that Change Daily pwk Excel Discussion (Misc queries) 0 January 8th 07 05:27 PM
How to link cells in two workbooks that change daily? Doc Adams Excel Discussion (Misc queries) 2 May 14th 06 08:47 PM
XL97 changes filenames upon open CLR Excel Discussion (Misc queries) 5 December 6th 05 05:56 PM
Macro to Open all workbooks in a folder and change default font Carlton A. Barlow Excel Programming 1 October 15th 04 01:38 PM


All times are GMT +1. The time now is 11:49 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"