Using a macro to pull data from a spreadsheet that changes its name daily

shina67

Board Regular
Joined
Sep 18, 2014
Messages
141
Hi All,

I have recorded a macro to pull data from various different spreadsheets to help determine throughput capacities.
The issue I have is that one of the spreadsheets changes name daily.
The line in the macro that this refers to is:-
Windows("Express Schedule 5-11am.xlsm").Activate

My question is how to I get the macro to pull the data from example "Express Schedule 6-11am.xlsm" and then "Express Schedule 7-11am.xlsm" as the new spreadsheet is created.

Hope this makes sense and thanks in advance for any help.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Re: Using a macro to pull data from a spreadsheet that changes it's name daily

Hello there. If the date will always be today's date, this will work. Replace the line Windows("Express Schedule 5-11am.xlsm").Activate with:
Code:
datebit = Format(Date, "d-mm")
fname = "Express Schedule " + datebit + "am.xlsm"
Windows(fname).Activate
 
Upvote 0
Re: Using a macro to pull data from a spreadsheet that changes it's name daily

Hi, Thanks for that. However, I forgot to mention that the "am" part of the spreadsheet name could also be pm. The date will always be today's date
Hello there. If the date will always be today's date, this will work. Replace the line Windows("Express Schedule 5-11am.xlsm").Activate with:
Code:
datebit = Format(Date, "d-mm")
fname = "Express Schedule " + datebit + "am.xlsm"
Windows(fname).Activate
 
Upvote 0
Re: Using a macro to pull data from a spreadsheet that changes it's name daily

I thought it might be. Use these 2 lines:
Code:
datebit = Format(Date, "d-mmam/pm")
fname = "Express Schedule " + datebit + ".xlsm"
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top