Opening a file with a cell name

joseoom

Board Regular
Joined
Oct 15, 2004
Messages
100
I want to open a file with a macro that would have to change the name of the file every day.

The file I want to open has the name according to the day. What I need is for my macro to open every day with the name thats on cell A1.

What I thought, and didn´t work was:

Workbooks.Open Filename:="W:\Corretor\Operações\cells("P2").value.xls", Notify:=False
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this:
Workbooks.Open Filename:="W:\Corretor\Operações\" & range("P2") & ".xls", Notify:=False
 
Upvote 0
How can I change that code so that the content of the "P2" cell is used as value. Just because I need the format dd/mmm to be preserved.
 
Upvote 0
Workbooks.Open Filename:="W:\Corretor\Operações\" & format(range("P2"),"dd-mmm") & ".xls", Notify:=False

this will give you a filename like :
W:\Corretor\Operações\15-jan.xls.xls
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,506
Members
449,089
Latest member
RandomExceller01

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