I am trying to devise a formula which will enable me to count an array of
cells which contain text and numbers. I then want to ignore the text and
just add the numbers e.g. (cells spread over worksheet, containing
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
LDS9
ES7.5 E L LD NS11 etc. The answer to this would be 27.5 (all th numbers
added together), is this possible?
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Not sure what you mean by "count an array of cells which contain text and
numbers"...
Do you want to find only the cells which contain text and numbers when some
of the cells only contain text but no numbers?
To get rid of the text that is not a number try this:
=IF(MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))>LEN(A1),"",(LEFT(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},RIGHT(A1,255)&"0123456789")),LEN(A1)),MIN(SEARCH({"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","
"},MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},RIGHT(A1,255)&"0123456789")),LEN(A1))&"abcdefghijklmnopqrstuvwxyz
"))-1)*1))
The above formula looks into the string to see if it contains a number. If
it does, it then locates the position of the left-most number within the
string and now works with the string beginning with that number (this
eliminates the characters at the beginning that are not numbers). Then it
looks left-to-right to find the position of the first letter or space to the
right of that string. That result is used in the overall LEFT function to
determine how many charaters are returned. 1 is subtracted from the
position of the first letter or space so the letter or number itself is not
included in the result. The result is multiplied by 1 to convert the still
text result to a numerical result.
To get the total of the results, use a formula something like this which
will ignore any errors:
SUMIF(A1:A10,">=0")
Notes on the formula:
Assumes all positive numbers.
Assumes only numbers, letters, and spaces in strings.
No spaces in numbers or letters between numbers permitted (only the number
before a space or letter will be returned).
No multiple numbers (i.e. separated by non-numerical characters).
Up to 255 characters in string (may be increased if necessary)
Decimal numbers OK
A non-letter character to the right of and adjacent to a number will cause
an error (except for a decimal point).
Bob