Possible for Formula to Referencing Future Worksheet?

hop17

New Member
Joined
Aug 19, 2009
Messages
12
Does anyone know if it's possible to reference a worksheet that has not yet been created, avoiding the #REF! result?

The formula I have is correct, however the macro generates new worksheets throughout the month in which the totals sheet is referencing. The problem being that the totals sheet is referencing worksheets not yet created.

Hoping someone knows a work-around....thanks!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi and welcome to the Board!!
Here's a Workaround
Name new first sheet named Start and a new last Sheet named Last. Now refer to your Totals like
=-SUM(First!A1:Last!A1). Adjust your macro to insert your new sheets before Last.
Oh, then you can hide First and Last!!

lenze
 
Upvote 0
Sure...

So here is the formula, which works correctly and is referencing worksheet "01" (for the first day of the month).

=IF(ISERROR(VLOOKUP(A6,'01'!$B$68:$K$128,10,FALSE)),"",(VLOOKUP(A6,'01'!$B$68:$K$128,10,FALSE))

Below is what I have for worksheet "02" because the "02" worksheet has not yet been created by the macro

=IF(ISERROR(VLOOKUP(A6,#REF!$B$6:$K$30,10,FALSE)),"",(VLOOKUP(A6,#REF!$B$6:$K$30,10,FALSE)))

Once I run the macro, "02" will be in the worksheet, however the formula will not work, unless I go back to it and enter "02" where I'm getting #REF!.
 
Upvote 0
Hi Lenze,

Thanks for the welcome. In the post above, I show the formula I'm working with. Would you be so kind as to tweak my formula to what you are specifying with the START and END worksheets. I think I follow, but would be very helpful to see.

Thanks!
 
Upvote 0
Hi

You can use Indirect()

=IF(ISERROR(VLOOKUP(A6,INDIRECT("'02'!$B$6:$K$30"),10,FALSE)),"",(VLOOKUP(A6,INDIRECT("'02'!$B$6:$K$30"),10,FALSE)))
 
Upvote 0
I'm not sure that approach will work for what you are doing. Could you not write your formula for non-existing sheets, but have your macro add the formula after it creates the new sheet??

lenze
 
Upvote 0
Hi

You can use Indirect()

=IF(ISERROR(VLOOKUP(A6,INDIRECT("'02'!$B$6:$K$30"),10,FALSE)),"",(VLOOKUP(A6,INDIRECT("'02'!$B$6:$K$30"),10,FALSE)))

You can also use a cell reference in the place of '02' if that helps in the creation of the formulas...
 
Upvote 0
Thanks for the feedback. I've tried the indirect function, but was still getting the #REF! error.

Also, in terms of macro, right now the macro takes the data from a sheet, copies and pastes (numbers only, no formulas) to a new worksheet and renames the new workbook by date (01,02,03 etc...)

Open to any work-arounds with the macro, I'm just not that saavy with VB. For instance, would I have the macro create the new worksheet, rename it and then also enter a formula on the totals tab after the worksheet exists? If I go that route, how will the macro know where the formula should go on future days with different worksheet names?
 
Upvote 0
OK, can you post your macro and tell us where you want the formulas to go on the Totals Sheet? In a column, Every 5th Row? Certain Cells related to the sheet name?

lenze
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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