Average with non-numeric characters and blanks in range (?)

bhodgman

New Member
Joined
Dec 31, 2016
Messages
7
Need help with a formula for the average of the following range, ignoring the blanks and text cells ('DNP' and 'NA'), but treating any number preceded by a '^' as that number:

<table cellspacing="0" cellpadding="0" dir="ltr" border="1" fixed;="" font-family:="" arial,="" sans,="" sans-serif;="" border-collapse:="" collapse;="" border:="" 1px="" solid="" rgb(204,="" 204,="" 204);"="" width=""><colgroup><col style="width: 100px;"></colgroup><tbody>[TR]
[TD="align: right"]NA[/TD]
[/TR]
[TR]
[TD="align: right"]^4[/TD]
[/TR]
[TR]
[TD="align: right"]DNP[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]NA[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]^1[/TD]
[/TR]
</tbody></table>

So formula for average of the above would return an answer of '3' - (4+5+2+1 / these four values =3).

Thoughts? I think it needs to be array entered with some combination of SUBSTITUTE and ISNUMBER, but I just can't figure out the syntax... Thanks!!!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Control+shift+enter, not just enter:

=AVERAGE(IF(ISNUMBER(SUBSTITUTE(A2:A9,"^","",1)+0),SUBSTITUTE(A2:A9,"^","",1)+0))


Thank you for trying, but that doesn't seem to work - that returns a value of '2' instead of '3'.

If the range is:

NA
(blank cell)
^3
2
^1
4
DNP

the formula needs to return a value of 2.5 (average of 3+2+1+4).
 
Upvote 0
Seems to work OK here:


Excel 2016 (Windows) 32 bit
ABC
2NA2.5
3
4^3
52
6^1
74
8DNP
Sheet2
Cell Formulas
RangeFormula
C2{=AVERAGE(IF(ISNUMBER(SUBSTITUTE(A2:A9,"^","",1)+0),SUBSTITUTE(A2:A9,"^","",1)+0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Note the '(blank cell)' means an empty cell -- it doesn't actually contain the text '(blank cell)'.

thus =AVERAGE(IF(ISNUMBER(SUBSTITUTE(A2:A9,"^","",1)+0),SUBSTITUTE(A2:A9,"^","",1)+0))

returns 2.4 with that second cell in the range as empty...
 
Upvote 0
There is something odd about your data, then: is one of the numbers actually text? Are the numbers all appearing flush left or right in their cells?

It works here correctly on both sets of data provided by you so far.

EDIT: Is that 'blank' cell really blank, or does it contain a formula? If so, what is the formula?
 
Last edited:
Upvote 0
Hmmm.... I'm actually using Google Sheets, and now noticed that if the blank cells are filled with some text, the formula seems to returns the correct value...

I thought the syntax between Google Sheets and Excel was essentially identical... but perhaps not... ugghh....
 
Upvote 0

Forum statistics

Threads
1,214,539
Messages
6,120,100
Members
448,944
Latest member
SarahSomethingExcel100

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