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 ...
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
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:

prajay

New Member
Joined
Sep 2, 2018
Messages
10
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>
 

p85ki

New Member
Joined
Nov 7, 2015
Messages
3
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.
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
You didn't answer the question if it's Always 4 digits, so use this, you can expand the Range of cells to suit:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Total</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">1000W.</td><td style=";">1000d</td><td style=";">1000c.</td><td style=";">1000o</td><td style="text-align: right;;">4000</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">1000W.</td><td style=";">1000d</td><td style=";">1200c.</td><td style=";">1000o</td><td style="text-align: right;;">4200</td></tr></tbody></table><p style="width:6.4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet222</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E2</th><td style="text-align:left">=SUMPRODUCT(<font color="Blue">LEFT(<font color="Red">A2:D2,4</font>)*1</font>)</td></tr></tbody></table></td></tr></table><br />
 

prajay

New Member
Joined
Sep 2, 2018
Messages
10
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....?
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
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:

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,802
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:

prajay

New Member
Joined
Sep 2, 2018
Messages
10
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>
 

prajay

New Member
Joined
Sep 2, 2018
Messages
10
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:)
 

Forum statistics

Threads
1,082,335
Messages
5,364,696
Members
400,811
Latest member
MSBINinja

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top