How to sum cell with any non numeric characters

prajay

New Member
Joined
Sep 2, 2018
Messages
10
FOR EXAMPLE
[TABLE="width: 500"]
<tbody>[TR]
[TD]1000W.
[/TD]
[TD]1000W

[/TD]
[TD]1000D.

[/TD]
[TD]1000E

[/TD]
[TD]4000

[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

HOW TO SUM ABOVE CASE TO GET ANSWER 4000 WITHOUT REMOVING TEXT & DOT OR ANY NON ALPHANUMERIC CHARACTER

GIVE ME VBA CODE OR SIMPLE FORMULA ...
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,

We need more information, are those values All in one cell, in 4 separate cells, will there be more cells, are they Always 4 digits, are the Alpha Always "W", "D", "E", and "."???

BTW, you need to get your keyboard fixed, I think your Caps Lock button is stuck?
 
Last edited:
Upvote 0
Sorry

all values are in separate cells no there is always different alpha characters along with dot somtimes

for example
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B1[/TD]
[TD]C1[/TD]
[TD]D1[/TD]
[TD]total[/TD]
[/TR]
[TR]
[TD]1000W.[/TD]
[TD]1000d[/TD]
[TD]1000c.[/TD]
[TD]1000o[/TD]
[TD]4000[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Following u to jtakw, if it is always 4 numbers with a character at the end, the simplist formula will be:

A1: 1000A
B1: 1000B

Formula: =SUM(VALUE(LEFT(A1,4))+VALUE(LEFT(B1,4)))

OR

A1: A1000
B1: B1000

Formula =SUM(VALUE(RIGHT(A1,4))+VALUE(RIGHT(B1,4)))

As there is text, i'm never sure if by putting the LEFT/RIGHT formula will convert this to a number, so I always add VALUE to ensure for certain this is always referred as a number, and always sum as well. You can write both formulas without the sum/value - so you have RIGHT/LEFT.
 
Upvote 0
You didn't answer the question if it's Always 4 digits, so use this, you can expand the Range of cells to suit:


Book1
ABCDE
1Total
21000W.1000d1000c.1000o4000
31000W.1000d1200c.1000o4200
Sheet222
Cell Formulas
RangeFormula
E2=SUMPRODUCT(LEFT(A2:D2,4)*1)
 
Upvote 0
Following u to jtakw, if it is always 4 numbers with a character at the end, the simplist formula will be:

A1: 1000A
B1: 1000B

Formula: =SUM(VALUE(LEFT(A1,4))+VALUE(LEFT(B1,4)))

OR

A1: A1000
B1: B1000

Formula =SUM(VALUE(RIGHT(A1,4))+VALUE(RIGHT(B1,4)))

As there is text, i'm never sure if by putting the LEFT/RIGHT formula will convert this to a number, so I always add VALUE to ensure for certain this is always referred as a number, and always sum as well. You can write both formulas without the sum/value - so you have RIGHT/LEFT.

Sometimes there is 3 or 2 or 4 or 5 or 6 numbers then how to sum....?
 
Upvote 0
Following u to jtakw, if it is always 4 numbers with a character at the end, the simplist formula will be:

A1: 1000A
B1: 1000B

Formula: =SUM(VALUE(LEFT(A1,4))+VALUE(LEFT(B1,4)))

OR

A1: A1000
B1: B1000

Formula =SUM(VALUE(RIGHT(A1,4))+VALUE(RIGHT(B1,4)))

As there is text, i'm never sure if by putting the LEFT/RIGHT formula will convert this to a number, so I always add VALUE to ensure for certain this is always referred as a number, and always sum as well. You can write both formulas without the sum/value - so you have RIGHT/LEFT.

Just FYI, you don't need the + if you're using SUM, or you don't need the SUM if you're using +

=SUM(VALUE(LEFT(A1,4)),VALUE(LEFT(B1,4)))
=VALUE(LEFT(A1,4))+VALUE(LEFT(B1,4)) ;)
 
Last edited:
Upvote 0
You could use this UDF with a formula like

=SUM(FirstValue(A1:D1))

Code:
Function FirstValue(inRange As Range) As Variant
    Dim Result As Variant
    Dim i As Long, j As Long
    With inRange
        If .Cells.Count = 1 Then
            Result = Val(CStr(.Cells(1, 1).Value))
        Else
            Result = .Value
            For i = 1 To .Rows.Count
                For j = 1 To .Columns.Count
                    Result(i, j) = Val(CStr(Result(i, j)))
                Next j
            Next i
        End If
    End With
    FirstValue = Result
End Function

This approach will handle data that has varying lengths of leading numerals.
 
Last edited:
Upvote 0
You didn't answer the question if it's Always 4 digits, so use this, you can expand the Range of cells to suit:

ABCDE
Total
1000W.1000d1000c.1000o
1000W.1000d1200c.1000o

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]4000[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]4200[/TD]

</tbody>
Sheet222

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E2[/TH]
[TD="align: left"]=SUMPRODUCT(LEFT(A2:D2,4)*1)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

thank you its working fine if some times different digits like 2 or 3 or 4

Total
1000W.1000d10c.999o
1000W.100d999c.h

<colgroup><col width="25px" style="background-color: rgb(218, 231, 245);"><col><col><col><col><col></colgroup><thead>
[TH="align: center"][/TH]
[TH="align: center"]A[/TH]
[TH="align: center"]B[/TH]
[TH="align: center"]C[/TH]
[TH="align: center"]D[/TH]
[TH="align: center"]E[/TH]

</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]?[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]?[/TD]

</tbody>


****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
ABCDE
Total
1000W.1000d1000c.1000o
1000W.1000d1200c.1000o

<thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]4000[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]4200[/TD]

</tbody>
Sheet222
</body>
 
Upvote 0
You could use this UDF with a formula like

=SUM(FirstValue(A1:D1))

Code:
Function FirstValue(inRange As Range) As Variant
    Dim Result As Variant
    Dim i As Long, j As Long
    With inRange
        If .Cells.Count = 1 Then
            Result = Val(CStr(.Cells(1, 1).Value))
        Else
            Result = .Value
            For i = 1 To .Rows.Count
                For j = 1 To .Columns.Count
                    Result(i, j) = Val(CStr(Result(i, j)))
                Next j
            Next i
        End If
    End With
    FirstValue = Result
End Function

This approach will handle data that has varying lengths of leading numerals.

Its working fine with all condition ... thank you so much:)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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