Sum numbers from text&num array?

ljubo_gr

Board Regular
Joined
Dec 6, 2014
Messages
244
Office Version
  1. 2016
Platform
  1. Windows
Hello,
i need help of looking an array of data, please Find {0,1,2,3,4,5,6,7,8,9}, and then Sumproduct.

W50150s768Q737
5564Y325X700065000
K15001200C33002500
1200e700b1001000

<tbody>
</tbody>


Result should be: 91,094 units. Text will mostly be single char letter, always in front, from beginning.
THANKS in advance!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Someone might be able to give you something more efficient but this should do it:

=SUMPRODUCT(ISTEXT(A1:D4)*MID(A1:D4,2,255))+SUM(A1:D4)

EDIT: nevermind, didn't realize you said mostly, so it can be 2 or more text characters. Go with the vba solution below.
 
Last edited:
Upvote 0
heres a UDF

Code:
Function sumranges(ParamArray cellranges() As Variant)
Dim cell As Range, i As Long, area As Variant
For Each area In cellranges
If TypeName(area) = "Range" Then
For Each cell In area
If Asc(UCase(cell)) > 64 And Asc(UCase(cell)) < 91 Then
i = i + (Mid(cell, 2, 256) + 0)
Else
i = i + cell
End If
Next
End If
Next
sumranges = i
End Function
 
Upvote 0
Thank you very much BarryL, but prefer formula, I already have dozens of codes inside wbook.

I don't know why this pgc01 doesn't work, could be sum cell is on another sheet?
Code:
=SUMPRODUCT(0+{"6000"\""\""\"";""\"1500"\""\"";"31550"\""\""\"";"6000"\""\""\"";"3000"\""\""\"";"11000"\""\""\"";"10000"\""\""\"";"4765"\""\""\"";"6000"\""\""\"";"5970"\""\""\"";"12000"\""\""\"";"6000"\""\""\"";"25000"\""\""\"";"7000"\""\""\"";"2000"\""\""\"";"6975"\""\""\"";"31040"\""\""\"";""\"20000"\""\"";""\"12520"\""\"";""\"32740"\""\"";""\"12010"\""\"";""\"6000"\""\"";""\"2500"\""\"";""\"8000"\""\"";""\"2000"\""\"";""\"19000"\""\"";""\"6000"\""\""})
 
Upvote 0
See if pgc's formula with a small adjust works

=SUMPRODUCT(0+MID(A1:D4&"0",1+ISTEXT(A1:D4),9))/10

M.
 
Upvote 0
Oi Marcelo, why add the 0 to divide it off?

OP this works on the sample you posted.

To deal with blank cells.
The formula adds a zero to each cell, so a blank cell becomes "0", but the numbers become greater (multiplied by 10) - that's why we need to divide the final result by 10.

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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