Vlookup and #N/A

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
168
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have 12 workbooks called 01 Jan, 02 Feb, 03 Mar etc which are created from a template. (i.e. one for each month of the year).

Within the workbook I have individual sheets called Sheet1 thru to Sheet5 which hold weekly dates for the individual weeks in the month. Sheet1 always starts of being the first Sunday of month, sheet2 will be the next Sunday within that month etc.

I then have a sheet called “Monthly Totals” which by using the following array formula extracts details from Sheet1, Sheet2 etc. The formula is:-

VBA Code:
=VLOOKUP($A2,INDIRECT("'"&INDEX(SheetList,MATCH(1,--(COUNTIF(INDIRECT("'"&SheetList&"'!$B$4:$V$10"),$A2)>0),0))&"'!$B$4:$V$10"),2,FALSE)
and it is present rows B2 to A32 in columns B to V.

Col A2 in Monthly Totals has a date starting as the first Sunday of the month, A3:A32 has the following formula:-

Code:
=IFERROR(IF(Formula!F$2-(A2+1)>=0, A2+1,""),"")
, where Formula!F$2 is the end of the month for the month in question.

The above formula will populate A2:A32 with just the date with the number of days in the month. Months like Feb and those that contain 30 days in the month, in Column A will only be populated with the exact number of days for the month

The problem I have, is as some months only have 30 days, the Vlookup reports #N/A for the 31st of those months and obviously February will report the 29th, 30th and 31st as #N/A.

In Row 33, I use the following formula:-

Code:
=SUMIF($A$2:$A$32,"<>",B2:B32)
to sum all the data for the month.

Is there any way to automate that for months with less than 31 days, the Vlookup in the appropriate rows for columns B to V either remove the formula or do not give #N/A? as it is hampering the formula
Code:
=SUMIF($A$2:$A$32,"<>",B2:B32)
to sum all the data for the month in row 33. People have to remember to remove the Vlookup in rows that do not have a date to get the totals in Row 33.

Thanks.
 
the ISNA and IFERROR and both work) and bingo it works.
IFNA not ISNA
if you will use a number or digit you don't need quotes, eg. ,0) , only for text, eg. ,"anytext")

You are welcome
 
Last edited:
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

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