Need a formula to ignore #N/A, but use zeros

stacyrae7

New Member
Joined
Mar 16, 2011
Messages
2
I have a spreadsheet where I am trying to write a formula to calculate an average. The columns being used may be blank or #N/A, which I want to ignore in the formula. Or it may contain a zero or a number 1 - 5 that I want to be used.

A1 A2 A3 A4 A5 A6
0 1 #N/A 3 5 blank

I'm looking for the average
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I have a spreadsheet where I am trying to write a formula to calculate an average. The columns being used may be blank or #N/A, which I want to ignore in the formula. Or it may contain a zero or a number 1 - 5 that I want to be used.

A1 A2 A3 A4 A5 A6
0 1 #N/A 3 5 blank

I'm looking for the average
Try this array formula**.

=IF(COUNT(A1:A6),AVERAGE(IF(ISNUMBER(A1:A6),A1:A6)),"")

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0
Welcome to the forums!

Ideally, you want to get rid of the errors at the source rather than trying to compensate for them in formulas further down the line. This way, you don't have to create an array-entered formula that checks for errors each time.

The easiest way to do this is for the cells where you have the formulas that can error, use:

Excel 2003 or older:
=IF(ISERROR(*your formula*),"",*your formula*)

Excel 2007 or newer:
=IFERROR(*your formula*,"")
 
Upvote 0
Try this array formula**.

=IF(COUNT(A1:A6),AVERAGE(IF(ISNUMBER(A1:A6),A1:A6)),"")

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.

THANK YOU, THANK YOU, THANK YOU, T. VALKO! This formula did exactly what I was looking for!
 
Upvote 0
FWIW, another alternative:

Code:
=IF(COUNT(A1:A6),SUMIF(A1:A6,">=-9.99E+307")/COUNT(A1:A6),"")
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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