Add cell in one column result in different column

sarah1024

New Member
Joined
Oct 15, 2018
Messages
7
Hello,
I need help with VBA code inserting sum of cells in column R in to column T which are separated by two empty rows.
values in column R starts at row 2.

Here is an example:

[TABLE="width: 150"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column R[/TD]
[TD]Column T[/TD]
[/TR]
[TR]
[TD]258.05[/TD]
[TD]567.42[/TD]
[/TR]
[TR]
[TD]309.37[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]426.19[/TD]
[TD]930.44[/TD]
[/TR]
[TR]
[TD]504.25[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]608.14[/TD]
[TD]608.29[/TD]
[/TR]
[TR]
[TD]0.15[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I greatly appreciate the help!

Thank you!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hello,

Is there a real necessity to have VBA ... when a formula can perform the calculation ...? :wink:
 
Upvote 0
Welcome to the MrExcel board!

Assuming column R numbers are not the result of formulas, try this in a copy of your workbook.
Code:
Sub Insert_Sum()
  Dim rA As Range
  
  For Each rA In Columns("R").SpecialCells(xlConstants, xlNumbers).Areas
    rA.Cells(1, 3).Value = Application.Sum(rA)
  Next rA
End Sub
 
Upvote 0
Hello,

In cell T2, you can test the Array formula :

Code:
=SUM(OFFSET(R2,0,0,MATCH(TRUE,ISBLANK(R3:$R$100),0),1))

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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