Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Summing columns after insert rows

I have a macro that goes down row by row and checks the previous rows date.
If it is different it inserts two new blank lines. Once this is completed, I
want to sum the new columns. Using the record macro, it recorded the first
block of numbers and then copied the formula over to the next two columns.

Range("E8").Select
Selection.End(xlDown).Select
Range("E14").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-6]C:R[-1]C)"
Range("D14").Select
ActiveCell.FormulaR1C1 = "Total "
Range("E14").Select
Selection.Copy
Range("F14:G14").Select
ActiveSheet.Paste
Range("H14").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=+RC[-3]+RC[-2]"
Range("H14").Select
Range("E14").Select
Selection.End(xlDown).Select

to move down to the next block of numbers.

--
Thanks,
Tom Cote
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Summing columns after insert rows

Sub AddFormula()

Dim startrow As Long
Dim sumrow As Long
startrow = 8
Do Until Cells(startrow, "E") = ""
sumrow = Cells(startrow, "E").End(xlDown).Row + 1

With Range(Cells(sumrow, "E"), Cells(sumrow, "H"))
.FormulaR1C1 = "=SUM(R" & startrow & "C:R[-1]C)"
End With

startrow = sumrow + 2 ''check!
Loop

End Sub

"Tom Cote" wrote:

I have a macro that goes down row by row and checks the previous rows date.
If it is different it inserts two new blank lines. Once this is completed, I
want to sum the new columns. Using the record macro, it recorded the first
block of numbers and then copied the formula over to the next two columns.

Range("E8").Select
Selection.End(xlDown).Select
Range("E14").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-6]C:R[-1]C)"
Range("D14").Select
ActiveCell.FormulaR1C1 = "Total "
Range("E14").Select
Selection.Copy
Range("F14:G14").Select
ActiveSheet.Paste
Range("H14").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=+RC[-3]+RC[-2]"
Range("H14").Select
Range("E14").Select
Selection.End(xlDown).Select

to move down to the next block of numbers.

--
Thanks,
Tom Cote

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Summing columns after insert rows

This worked great and it seems to take care of the blocks that just have one
date. I should be able to modify to add formatting. Thanks again.
--
Thanks,
TC


"Patrick Molloy" wrote:

Sub AddFormula()

Dim startrow As Long
Dim sumrow As Long
startrow = 8
Do Until Cells(startrow, "E") = ""
sumrow = Cells(startrow, "E").End(xlDown).Row + 1

With Range(Cells(sumrow, "E"), Cells(sumrow, "H"))
.FormulaR1C1 = "=SUM(R" & startrow & "C:R[-1]C)"
End With

startrow = sumrow + 2 ''check!
Loop

End Sub

"Tom Cote" wrote:

I have a macro that goes down row by row and checks the previous rows date.
If it is different it inserts two new blank lines. Once this is completed, I
want to sum the new columns. Using the record macro, it recorded the first
block of numbers and then copied the formula over to the next two columns.

Range("E8").Select
Selection.End(xlDown).Select
Range("E14").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-6]C:R[-1]C)"
Range("D14").Select
ActiveCell.FormulaR1C1 = "Total "
Range("E14").Select
Selection.Copy
Range("F14:G14").Select
ActiveSheet.Paste
Range("H14").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=+RC[-3]+RC[-2]"
Range("H14").Select
Range("E14").Select
Selection.End(xlDown).Select

to move down to the next block of numbers.

--
Thanks,
Tom Cote

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert rows and columns inside a single cell? Neo Excel Discussion (Misc queries) 3 May 17th 23 11:46 AM
CANT INSERT CELLS, ONLY ROWS & COLUMNS robin l Excel Worksheet Functions 1 April 16th 09 05:43 PM
Insert many columns with many rows AFTER data has already been typ CLR Excel Discussion (Misc queries) 0 March 30th 09 04:12 PM
How do I insert collapsable columns/rows into a worksheet? Ginger Excel Discussion (Misc queries) 1 July 23rd 07 03:40 AM
summing rows and columns RKS Excel Discussion (Misc queries) 2 April 14th 07 03:50 AM


All times are GMT +1. The time now is 05:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"