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.
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.
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
You didn't answer the question if it's Always 4 digits, so use this, you can expand the Range of cells to suit:
A B C D E 1 Total 2 1000W. 1000d 1000c. 1000o 4000 3 1000W. 1000d 1200c. 1000o 4200
<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>Sheet222
Worksheet Formulas
Cell Formula E2 =SUMPRODUCT(LEFT(A2:D2,4)*1)
<thead>
</thead><tbody>
</tbody>
<tbody>
</tbody>
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Total | ||||
2 | 1000W. | 1000d | 10c. | 999o | ? |
3 | 1000W. | 100d | 999c. | h | ? |
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Total | ||||
2 | 1000W. | 1000d | 1000c. | 1000o | 4000 |
3 | 1000W. | 1000d | 1200c. | 1000o | 4200 |
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.