Macro to replace part of a formula

Pedro Morais

Board Regular
Joined
Dec 5, 2007
Messages
90
Hey guys,

I'm trying to create a macro to replace a link on a formula.
The formula is as below
='[Players Report 31121999.xls]Player1'!$AK$23

Where 31121999 is the date. there's a workbook everyday with different sheets for every player
I want to have a macro that gets the date I inputed in another cell and changes the date in the formula I displayed above (just changing the date).
Do you guys think thats possible?

Cheers
Pedro
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Welcome to the Board!

Why not use indirect without usign a macro. Not sure what cell your inputted date is in, but I have just assumed A1:

Code:
=Indirect("'[Players Report " & A1 & ".xls]Player1'!$AK$23")

Change the cell reference as necessary.

Also with the morefunc add-in you can use Indirect.Ext() and it will pull values from a closed workbook. Morefunc is located at this website if you want to download it:

http://xcell05.free.fr/english/
 
Upvote 0
Yes, you can certainly do what you're asking using VBA. A non-VBA alternative would be to the date of interest in a cell and name the cell MyDate or something similarly brilliant and alter the formula to read: <ul>[*]=Indirect("'[Players Report " & MyDate & ".xls]Player1'!$AK$23")[/list]Then as you change the date, the formula will change.
 
Upvote 0
schielrn, a rather brilliant suggestion you made there. :wink: You might wanna edit it to put a double quote right in front of the closing parenthesis.

<sup>edit</sup> Dagnabit, 2<sup>nd</sup> time today I'm a fergettin' me blasted manners... Welcome to MrExcel, Pedro! ...sheesh... :rolleyes: <sub>/edit</sub>
 
Upvote 0
Thanks

wow... i already tried to get parts of text & cell value together but I didn't know how.. I tried concatenate :S ...

Anyways, I copied the code and even inputed the date in cell A1, but it says the formula has an error...

Any idea why?
Thanks a mil
 
Upvote 0
You might need to alter the formula to sumpin' like:<ul>[*]=Indirect("'[Players Report " & Text(A1,"ddmmyyyy") & ".xls]Player1'!$AK$23")[*]=Indirect("'[Players Report " & Text(MyDate,"ddmmyyyy") & ".xls]Player1'!$AK$23")[/list]
 
Upvote 0
Thanks for noticing that missing quote Greg. I have now edited. But now I think you have it right with the text format. i forgot that usually needs to be done when using indirect because I believe it is going to take the dates serial number or how it is formatted in the cell, but I just didn't test it.
 
Upvote 0
mmm not there yet...

the result of the part Text(A1,"ddmmyyyy") is #value...

A1 is formatted as "General"... does that interfer?

Sorry bout my inexperience guys :P
 
Upvote 0
What are you typing into A1? <ul>[*]31121999 ?[*]12/31/99 ?[/list]If you type just <ul>[*]="'[Players Report " & Text(A1,"ddmmyyyy") & ".xls]Player1'!$AK$23"[/list]into a cell what do you get?
 
Upvote 0

Forum statistics

Threads
1,215,833
Messages
6,127,157
Members
449,367
Latest member
w88mp

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