Reference value in A1 as part of file name

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
582
Office Version
  1. 365
Hi

I need to be able to reference a cell reference (which is a date such as 20230213) in cell A1, as par of a filename in a formula

So, in B1, I have =COUNTIF('[Table export20230213.xlsx]'!$A:$A,1)

However, what I would like to do is to be able to substitute the date part of the above to A1. (So, I can then just drag and drop down so all spreadsheets saved down will be able to be looked up without having to manually input each reference.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
How about
Excel Formula:
=COUNTIF(INDIRECT("'[Table export"&A1&".xlsx]'!$A:$A"),1)
or
Excel Formula:
=COUNTIF(INDIRECT("'[Table export"&TEXT(A1,"yyyymmdd")&".xlsx]'!$A:$A"),1)
 
Upvote 0
Apologies, I did not include the sheet reference, so I cannot get it to work...

Excel Formula:
=COUNTIF('[Table export20230213.xlsx]Lookup Table export'!$A:$A,1)



How about
Excel Formula:
=COUNTIF(INDIRECT("'[Table export"&A1&".xlsx]'!$A:$A"),1)
or
Excel Formula:
=COUNTIF(INDIRECT("'[Table export"&TEXT(A1,"yyyymmdd")&".xlsx]'!$A:$A"),1)
 
Upvote 0
if you remove the '! from after the ] then it should be ok.
 
Upvote 0
Thank you for this - the formula works, but only wen the spreadsheet is opened, otherwise it goes back to #REF! - Is there anyway it can work so that it "Saves" whatever data was the result when the sheet was last opened please?

(So, I would like to save down the spreadsheet with the name, the results store in my master spreadsheet, and then I close it down. A process I can repeat every day, so I can have the master sheet with a daily total in?
if you remove the '! from after the ] then it should be ok.
 
Upvote 0
You can only use indirect with an open workbook. To save the data you would have to copy & paste as values.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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