![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 15
|
I have a series of file names which have the naming convention mmmddblahblah.xls, whereby mmm refers to the first 3 letters of the month and dd refers to the day of that month. For example, the file for April 7 would be named apr07blahblah.xls.
My question is: Is there a way I could write a macro to open up 7 sequential files (ie. April 27 - May 3) based upon the order of the months and their respective number of days, using the mmmdd part of their names? Thanks! StrangeLuck |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
I'm sure it's possible somehow. One of the questions that you'll probably be asked is from which date we'd be starting? Would you want to be able to determine that each time or would it start with, for instance, yesterday?
__________________
~Anne Troy |
|
|
|
|
|
#3 | |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Quote:
Thanks, StrangeLuck |
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Something like this would work (note:: there's some strange stuff in this, someone might want to debug this even more, but it does what you ask):
The "strange stuff" is partly to do with the way Excel handles dates and partly to do with the "Format" statement. For some reason, the Format statement was giving my "26" for the first day. Anyway, I hope this helps. |
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
|
What are you storing in those files? Is it just some generic data in a particular format in each workbook? Have you ever considered storing the data in these files in a single Access database and using queries to load relevant data into a single workbook at runtime?
|
|
|
|
|
|
#6 | |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Quote:
|
|
|
|
|
|
|
#7 | |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Quote:
|
|
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Well, since you used a smiley, I've created a stunted Excel 97 version of the function copy and paste this into your module:
Private Function MonthName97(ByVal iMonth As Integer)
Then use this line of code (instead of the old one:
HTH |
|
|
|
|
|
#9 | |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Quote:
Thanks, StrangeLuck |
|
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Use this:
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|