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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Bruno

Active Member
Joined
Feb 17, 2002
Messages
491
Try this:
Workbooks.Open Filename:="W:\Corretor\Operações\" & range("P2") & ".xls", Notify:=False
 

joseoom

Board Regular
Joined
Oct 15, 2004
Messages
100
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.
 

Bruno

Active Member
Joined
Feb 17, 2002
Messages
491
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,232
Messages
5,594,962
Members
413,954
Latest member
mrsandy

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
Top