Sum value with simmilar parameters

knaabis

Active Member
Joined
Apr 25, 2006
Messages
254
Office Version
  1. 2013
Platform
  1. Windows
How to SUM by VBA simmilar dimensions (for example - 16 65 185, 16 65 380, 22 75 898)values (Pcs) from column D and get result in column E (Sum).
These SUM I have already put in example in column E.
SpecifikacijaTest1.xls
ABCDE
1
2
3DimensionsPcsSum
4166518510
516651855
61665185318
716653808
8166538019
9
10227589844
Sheet1
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Have you considered creating a PivotTable to do this for you?

Excel Workbook
ABCD
1
2
3Dimension1Dimension2Dimension3Pcs
4166518510
516651855
616651853
716653808
816653801
922758984
10
11Sum of Pcs
12Dimension1Dimension2Dimension3Total
13166518518
143809
1522758984
16Grand Total31
Sheet11
 
Upvote 0
Not, i need accurately SUM in these places what you see in sample and by VBA.
 
Upvote 0
Have you tried to write the VBA at all? Have you got any sample code to show?
 
Upvote 0
I get code, but it work if two or more rows will be summed.
If only one row, then i get wrong result.
SpecifikacijaTest2.2.xls
ABCD
1
2
3
4
5
6DimensionsPcs
7166518510
816651855
916651853
10
1116653808
1216653801
13
1422758984
15
16256538010
17256538020
18
Sheet1


Sub Sum_In_Empty_Row()
LR = Range("d7").End(xlDown).Row + 1
LR1 = Range("c" & LR - 1).End(xlUp).Row
Range("d" & LR).Select
ActiveCell.Value = Application.Sum(Range("d" & LR1 & ":d" & LR - 1))
End Sub

SUM values i will get in cells - D10, D13, D15, D18
For D10, D13, D18 is OK, but for D15 i get wrong result...
 
Last edited:
Upvote 0
This does what you want:
Code:
Sub Sum_In_Empty_Row_New()
    lastrow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
    irow = 7
    istart = 7
    Do Until irow > lastrow
        If Cells(irow, 4).Value = "" Then
            Cells(irow, 4).FormulaR1C1 = "=SUM(R" & istart & "C:R" & irow - 1 & "C)"
            istart = irow + 1
        End If
        irow = irow + 1
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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