Dynamic Named ranges in formula.

Phil Payne

Board Regular
Joined
May 17, 2013
Messages
131
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have set up the means to determine and count the number of public holidays during a year on a month by month basis.
They work but I need the calendars to be dynamic to allow local holidays to be added.
I have tried to set up a dynamic ranges to work within the existing formula to no avail, an error always occurs.

Can someone tell the what adjustments are needed to this working formula to make it work with dynamic range please?
=NETWORKDAYS(P2,EOMONTH(P2,0),Holiday_Calendars!$E$4:$E$13)

I would like to replace “Holiday_Calendars!$E$4:$E$13” part with a dynamic named range.

Any help is appreciated.

Holiday_Calendars and Data Sheet images attached for info:
 

Attachments

  • image_2023-08-14_135928158.png
    image_2023-08-14_135928158.png
    111.4 KB · Views: 12
  • SnipImage1.JPG
    SnipImage1.JPG
    13.7 KB · Views: 12

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

What is the name of your dynamic named range & how is it defined?
 
Upvote 0
My dynamic named range is not dynamic. I have problems creating it.
I have a named range only and even that won't work when combined with the rest of the formula.
My named Range is "Hols2022". I hope you can see the image OK.

I've taken your point about my Account Details - thanks will do.

For speed I am using MS 365 Apps for Enterprise
 

Attachments

  • SnipImage3.JPG
    SnipImage3.JPG
    29.4 KB · Views: 12
Upvote 0
Are the values in the Hols2022 range actual dates or text? As the formula should work quite happily with a named range.
 
Upvote 0
Well,

I tried a basic named range again "=NETWORKDAYS(M2,EOMONTH(M2,0),Hols2022)" and it worked.😊

So moving on I tried "=NETWORKDAYS(P2,EOMONTH(P2,0),Hols2023)" which did not work!!! Returns a #VALUE! error???😒

Formatted cell in Data Sheet presents long date 01 December 2022 (formula bar shows 01/01/2022)
The named range cell presents in exactly the same way!
 
Upvote 0
No it is not. I'm trying to get the basics right first.

FYI When I google I get this answer time and again:-
"To reference a cell or range of cells in another worksheet in the same workbook, put the worksheet name followed by an exclamation mark (!) before the cell address. For example, to refer to cell A1 in Sheet2, you type Sheet2!A1. For example, to refer to cells A1:A10 in Sheet2, you type Sheet2!A1:A10".

When I do that for the named range it insists on changing the worksheet name for the workbook(.xlsm) name md fails??
 
Upvote 0
As those named ranges are workbook scope, you do not put the sheet name infront of them, just use
Excel Formula:
=NETWORKDAYS(P2,EOMONTH(P2,0),Hols2022)
as you showed.

Although your named ranges for 2023 onwards look to conatin text which is the problem.
 
Upvote 0
Thank you Fluff,
You cracked the going forward issue for me.
I just need to make the ranges dynamic!
Can you help with that too?
Thanks.
 
Upvote 0
Will you ever have anything below the dates on the Holiday_calendars sheet?
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

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