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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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
sorry maybe not clear, my expected value in cell G10.. The core is how to sum data from cell G3 till G9. the data contains number, mark =, comma, dot , space
 
Upvote 0
the code not working, maybe someone to fix it.
after run the code the result is 0
VBA Code:
Sub AddCells()
Dim l, j As Long, w As Worksheet

Application.ScreenUpdating = False

j = 0
For Each w In ActiveWorkbook.Sheets
On Error Resume Next
    w.Select
    j = CLng(Replace(Replace(Replace(w.Range("C21").Value, "=", ""), ".", ""), ",", ".")) + j
Next
   MsgBox j
   
Application.ScreenUpdating = True
   
End Sub

note: the value content excessice spaces , 1 spaces before mark "=" and 1 spaces after mark "="
 
Last edited:
Upvote 0
the code not working, maybe someone to fix it.
after run the code the result is 0
VBA Code:
Sub AddCells()
Dim l, j As Long, w As Worksheet

Application.ScreenUpdating = False

j = 0
For Each w In ActiveWorkbook.Sheets
On Error Resume Next
    w.Select
    j = CLng(Replace(Replace(Replace(w.Range("C21").Value, "=", ""), ".", ""), ",", ".")) + j
Next
   MsgBox j
  
Application.ScreenUpdating = True
  
End Sub

note: the value content excessice spaces , 1 spaces before mark "=" and 1 spaces after mark "="
Not sure I understand what you want. The code below will sum the range G3:G9 on every worksheet and produce the aggregate sum for all worksheets. Assumes there are no errors or text not conforming to the format you show in any of the cells included in the ranges to be summed.
VBA Code:
Sub TextToNumbersSum()
Dim w As Worksheet, S As Double
For Each w In ActiveWorkbook.Worksheets
    For Each c In w.Range("G3:G9")
        S = S + Replace(Replace(Replace(c.Value, "=", ""), ".", ""), ",", "") + 0
    Next c
Next w
MsgBox Format(S, "#,##0")
End Sub
 
Upvote 0
Not sure I understand what you want. The code below will sum the range G3:G9 on every worksheet and produce the aggregate sum for all worksheets. Assumes there are no errors or text not conforming to the format you show in any of the cells included in the ranges to be summed.
VBA Code:
Sub TextToNumbersSum()
Dim w As Worksheet, S As Double
For Each w In ActiveWorkbook.Worksheets
    For Each c In w.Range("G3:G9")
        S = S + Replace(Replace(Replace(c.Value, "=", ""), ".", ""), ",", "") + 0
    Next c
Next w
MsgBox Format(S, "#,##0")
End Sub

ho JoeMo, i found new problem for this format MsgBox Format(S, "#,##0"), if the number format like eg. 877.000 or 1.500.999 or 22.100.000 or 150.750.000 or 1.165.700.000 or 12.500.600.000, how to modified Format Number like that
 
Upvote 0
ho JoeMo, i found new problem for this format MsgBox Format(S, "#,##0"), if the number format like eg. 877.000 or 1.500.999 or 22.100.000 or 150.750.000 or 1.165.700.000 or 12.500.600.000, how to modified Format Number like that
You can change the format in the message box to whatever you want. I thought you want to remove all the "." characters. What number would you convert say 12.500.600.000 to??
 
Upvote 0
You can change the format in the message box to whatever you want. I thought you want to remove all the "." characters. What number would you convert say 12.500.600.000 to??

hi Joe..

this related in my posting in VBA : Sum Every 22 Rows in a Sheet with Data Not Fully Number
i have try modify your code like this:
VBA Code:
Sub TextToNumbersSum()
Dim w As Worksheet, S As Double
lr = Cells(Rows.Count, "C").End(xlUp).Row
S = 0
    For r = 21 To lr Step 22
        Cells(r, 3).Value = Replace(Replace(Replace(Cells(r, 3).Value, "=", ""), ".", ""), ",", "")
        S = S + Cells(r, 3).Value
    Next r
MsgBox Format(S, "#,##0")
End Sub

or summing is correct but the mark of number is gone like mark =,comma,dot, not dissapear again
i want the mark is not gone, please see this picture, before and after run macro
 

Attachments

  • before.jpg
    before.jpg
    7.2 KB · Views: 4
  • after.jpg
    after.jpg
    6.3 KB · Views: 5
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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