Sum Data Contains String/Mark from Multiple Sheet into Same Cell

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..
i have dozen sheets, i want to sum data from multiple sheets. My position data always in cell C20 for each sheet.
my data contains string, mark =, space (in front mark=), mark . or ,
how to do it this:
here my data
LPK-2.010 All.xlsx
G
2data
3= 877.000,00
4= 1.200.000,00
5= 10.877.000,00
6= 115.877.000,00
7= 1.877.500.000,00
8= 10.900.600.000,00
9= 123.300.400.000,00
10sum??
Sheet1


any help, thanks all..
note :
can use formula or macro
.sst
 
hi...
yes. I have use regional setting use "." as the decimal separator and "," as the thousands separator. Of course yes, always use two digits after the last.
OK. Here's some code that carries out the sum to two decimal places, using the number format "#,##0.00". If that's what you are looking for, you can adapt it to sum every 22nd cell in col C if that's still your objective.
Book1
FGHIJKL
4Sample1Sample2Sample3Sample3Sample4Sample5
5= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
6= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
7= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
8= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
9Sum3,140,000.007,140,000.0043,140,000.00403,140,000.004,403,140,000.0044,403,140,000.00
Sheet1

VBA Code:
Sub test()
Dim R As Range, Col As Range, c As Range, S As Double, D As Double
Set R = Range("G5:L8")
Application.ScreenUpdating = False
For Each Col In R.Columns
    For Each c In Col.Cells
        If InStrRev(c.Value, ",") = Len(c.Value) - 2 Then ' there's a decimal amount
            D = D + Right(c.Value, 2) + 0
            S = S + Replace(Replace(Replace(Left(c.Value, Len(c.Value) - 3), "=", ""), ".", ""), ",", "") + 0
        Else
            S = S + Replace(Replace(Replace(c.Value, "=", ""), ".", ""), ",", "") + 0
        End If
    Next c
    With Cells(Rows.Count, Col.Column).End(xlUp).Offset(1, 0)
        .Value = S + D / 100
        .NumberFormat = "#,##0.00"
    End With
D = 0: S = 0
Next Col
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
OK. Here's some code that carries out the sum to two decimal places, using the number format "#,##0.00". If that's what you are looking for, you can adapt it to sum every 22nd cell in col C if that's still your objective.
Book1
FGHIJKL
4Sample1Sample2Sample3Sample3Sample4Sample5
5= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
6= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
7= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
8= 785.000,00= 1.785.000,00=10.785.000,00= 100.785.000,00= 1.100.785.000,00= 11.100.785.000,00
9Sum3,140,000.007,140,000.0043,140,000.00403,140,000.004,403,140,000.0044,403,140,000.00
Sheet1

VBA Code:
Sub test()
Dim R As Range, Col As Range, c As Range, S As Double, D As Double
Set R = Range("G5:L8")
Application.ScreenUpdating = False
For Each Col In R.Columns
    For Each c In Col.Cells
        If InStrRev(c.Value, ",") = Len(c.Value) - 2 Then ' there's a decimal amount
            D = D + Right(c.Value, 2) + 0
            S = S + Replace(Replace(Replace(Left(c.Value, Len(c.Value) - 3), "=", ""), ".", ""), ",", "") + 0
        Else
            S = S + Replace(Replace(Replace(c.Value, "=", ""), ".", ""), ",", "") + 0
        End If
    Next c
    With Cells(Rows.Count, Col.Column).End(xlUp).Offset(1, 0)
        .Value = S + D / 100
        .NumberFormat = "#,##0.00"
    End With
D = 0: S = 0
Next Col
Application.ScreenUpdating = True
End Sub

related similar problem this link VBA : Sum Every 22 Rows in a Sheet with Data Not Fully Number
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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