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 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
       [B] Cells(r, 3).Value [/B]= 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
The marks disappear because you set the value (in bold above) to the replacement.

See if this works for you:
VBA Code:
Sub TextToNumbersSum()
Dim w As Worksheet, S As Double
lR = Cells(Rows.Count, "C").End(xlUp).Row
For r = 21 To lR Step 22
    S = S + Replace(Replace(Replace(Cells(r, 3).Value, "=", ""), ".", ""), ",", "") + 0
Next r
MsgBox Format(S, "#,##0")
End Sub
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
hi
The marks disappear because you set the value (in bold above) to the replacement.

See if this works for you:
VBA Code:
Sub TextToNumbersSum()
Dim w As Worksheet, S As Double
lR = Cells(Rows.Count, "C").End(xlUp).Row
For r = 21 To lR Step 22
    S = S + Replace(Replace(Replace(Cells(r, 3).Value, "=", ""), ".", ""), ",", "") + 0
Next r
MsgBox Format(S, "#,##0")
End Sub
hi Joe, still not full work i mean for summing have problem, after run macro, the result not correct over 2 digits number in behind (zero number)
 
Upvote 0
hi

hi Joe, still not full work i mean for summing have problem, after run macro, the result not correct over 2 digits number in behind (zero number)
Like to help, but I have no idea what your data and data layout looks like. Can you post a sample and show the result you get and what your expected result is?
 
Upvote 0
Like to help, but I have no idea what your data and data layout looks like. Can you post a sample and show the result you get and what your expected result is?

hi..
this my sample assuming start from c21,....
AsummingSample1Sample2Sample3Sample3Sample4Sample5
in cell C21= 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
cell C43= 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
cell C65= 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
cell C87= 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
Expected (SUM)3.140.0007.140.00043.140.000403.140.0004.403.140.00044.403.140.000

note :
my target in line "expected (sum)" in one sheet not multiple sheet, and the result in Indonesia Format Number
 
Last edited:
Upvote 0
hi..
this my sample assuming start from c21,....
AsummingSample1Sample2Sample3Sample3Sample4Sample5
in cell C21= 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
cell C43= 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
cell C65= 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
cell C87= 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
Expected (SUM)3.140.0007.140.00043.140.000403.140.0004.403.140.00044.403.140.000

note :
my target in line "expected (sum)" in one sheet not multiple sheet, and the result in Indonesia Format Number
I can't test this because I don't have access to your regional settings. Try changing this:

Format(S, "#,##0")
to this:
Format(S, "#.##0")
in the line that has the message box.
You would need to add a loop for the other columns beyond column C.
 
Upvote 0
I can't test this because I don't have access to your regional settings. Try changing this:

Format(S, "#,##0")
to this:
Format(S, "#.##0")
in the line that has the message box.
You would need to add a loop for the other columns beyond column C.
hi.. i have doing your instruction and trying to change format number with several combination but the result of sum is wrong. maybe this not only about format number digits, or there some code missing it.
 
Upvote 0
hi.. i have doing your instruction and trying to change format number with several combination but the result of sum is wrong. maybe this not only about format number digits, or there some code missing it.
Can you post an example of where sum is wrong using XL2BB so I can copy the data easily? Also, ignoring the accuracy of the sum, is it formatted the way you want it to be?
 
Upvote 0
Can you post an example of where sum is wrong using XL2BB so I can copy the data easily? Also, ignoring the accuracy of the sum, is it formatted the way you want it to be?

hi...this my expected result in table and i attachment "sum of result" as picture after using your macro code
Book1
FGHIJKL
3AsummingSample1Sample2Sample3Sample3Sample4Sample5
4in cell C21= 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
5cell C43= 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
6cell C65= 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
7cell C87= 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
8My Expected (SUM - Correct) 3,140,000 7,140,000 43,140,000 403,140,000 4,403,140,000 44,403,140,000
9Sum Using Your Code (Not Correct) 314,000,000,000 714,000,000,000 4,314,000,000,000 etc.etc.etc.
Sheet1
 

Attachments

  • sample-1.png
    sample-1.png
    2 KB · Views: 2
  • sample-2.png
    sample-2.png
    1.9 KB · Views: 3
  • sample-3.png
    sample-3.png
    2 KB · Views: 2
Upvote 0
Do your regional settings use "." as the decimal separator and "," as the thousands separator? Will there always be only two digits after the last ","?
 
Upvote 0
Do your regional settings use "." as the decimal separator and "," as the thousands separator? Will there always be only two digits after the last ","?
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.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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