How to sum cell with any non numeric characters

prajay

New Member
Joined
Sep 2, 2018
Messages
10
FOR EXAMPLE
1000W.
1000W

1000D.

1000E

4000


<tbody>
</tbody>

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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
A1B1C1D1total
1000W.1000d1000c.1000o4000

<tbody>
</tbody>
 
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
1Total
21000W.1000d1000c.1000o4000
31000W.1000d1200c.1000o4200

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet222

Worksheet Formulas
CellFormula
E2=SUMPRODUCT(LEFT(A2:D2,4)*1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

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

ABCDE
1Total
21000W.1000d10c.999o?
31000W.100d999c.h?

<colgroup><col width="25px" style="background-color: rgb(218, 231, 245);"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>


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

<thead>
</thead><tbody>
</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,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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