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 ...
 
I'd just go with mikerickson's UDF, as a formula solution may get a little messy...
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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.

How to sum only with the specific character ?
for example ...
1000G. 1000M. 1000g 2000e. = i want to sum only cell having g or G = 2000
 
Upvote 0
How to sum only with the specific character ?
for example ...
1000G. 1000M. 1000g 2000e. = i want to sum only cell having g or G = 2000

Control+shift+enter, not just enter:

=SUM(IF(1-ISNUMBER(A2:D2),IF(ISNUMBER(SEARCH("G",A2:D2)),LEFT(A2:D2,SEARCH("G",A2:D2)-1)+0)))
 
Upvote 0
Control+shift+enter, not just enter:

=SUM(IF(1-ISNUMBER(A2:D2),IF(ISNUMBER(SEARCH("G",A2:D2)),LEFT(A2:D2,SEARCH("G",A2:D2)-1)+0)))


Thank you its working perfect.... great...

Now tell me how to count cell that contains specific characters

for example

1000d. 2000f 3000g 4000d 3000d. =count D answer 3
 
Upvote 0
Thank you its working perfect.... great...

Now tell me how to count cell that contains specific characters

for example

1000d. 2000f 3000g 4000d 3000d. =count D answer 3

Control+shift+enter, not just enter:

=SUM(IF(ISNUMBER(SEARCH("D",A2:D2)),1))

or just enter:

=COUNTIFS(A2:D2,"*"&"D"&"*")

"D" can be replaced by a cell address like J2 housing D as the search item.
 
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.

if there is any single alphabet alone in cell then it gives error value of #NAME ?

for example
1000d. 5000w. 3000e H 2000r =#NAME ? because of only alphabet present in cell
 
Upvote 0
if there is any single alphabet alone in cell then it gives error value of #NAME ?

for example
1000d. 5000w. 3000e H 2000r =#NAME ? because of only alphabet present in cell
I think the following UDF will give you the values you want...
Code:
Function SumRange(Rng As Range) As Double
  Dim Cell As Range
  For Each Cell In Rng
    SumRange = SumRange + Val(Cell.Value)
  Next
End Function
To use it, simply put this in the cell...

=SumRange(A1:D1)

where you would change the range as needed.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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