Iteration with IFNA and VLOOKUP

dmitryt

New Member
Joined
Jul 14, 2022
Messages
5
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi! I have sheet with following data:
1657796707891.png

WorkDates column contains dates, but only working days, public holidays are excluded.
I need to enter Date1 and Date2 and amount of average daily payment. For example:
Date1 is 01.01.2021 and Date2 is 03.01.2021, I can (Date3-Date1)x$100 = $200.
I am using VLOOKUP to find DateIndex from the table, but the is a problem if enter Date that is out of range of the table. For example Date1 is Sunday and there is not DateIndex for it. I've tried to use IFNA, but all it helps - to change NA value.
Is there any option without VBA to do Iteration (+1) IF NA returned and do it unless real DateIndex returned?
Some kind of Nested IFNA?

Logic example screenshot
1657796656525.png
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If you tried to lookup the 16th or 17 of Jan 2021 what should it return 5 or 6 or something else?
 
Upvote 0
it should return DateIndex of first Date that is available in the table.
If we put 16.01.2021 or 17.01.2021 in Date 1, it should return DateIndex 6 for Date 18.01.2021.
 
Upvote 0
Ok, how about
Excel Formula:
=VLOOKUP(WORKDAY(B2-1,1),Workdates!A2:B742,2,0)
 
Upvote 0
Ok, how about
Excel Formula:
=VLOOKUP(WORKDAY(B2-1,1),Workdates!A2:B742,2,0)
it does not help, because workdays are not only Sut-Sun, but different national local holidays too. For example if put 05.09.2021 - it returns NA.
I was thinking about IFNA go to next date, but how to increment next date in this case?
 
Upvote 0
Maybe it will be good to add Non-Working days in main table, add indexes and value 0 for Non-working days or 1 for Working days, then return 2 indexes and Sum Values. Will try.
 
Upvote 0
it does not help, because workdays are not only Sut-Sun, but different national local holidays too.
In that case you need to add the holiday dates into the workday function.
 
Upvote 0
OK, Finally I did it with
Excel Formula:
=SUMPRODUCT((A2:A1095>=H2)*(A2:A1095<=H3)*(C2:C1095=1))
but as I mentioned above - I enhanced main table - added All days into it, added Value 1 for working days and 0 for non-working days.
1657805440139.png
 
Upvote 0
You don't need to do that, you can just add the holiday list into the workday function
Excel Formula:
=VLOOKUP(WORKDAY(B2-1,1,Holidays),Workdates!A2:B742,2,0)
just replace the word Holidays with the range that holds you holiday dates.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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