need macro help

  • Thread starter Thread starter cturner
  • Start date Start date
C

cturner

I have 4 columns of data. I have text in column A, a date in column B,
number in C, and a number in D. I want to go down every four rows
insert a blank row, add up the numbers in column D and put the resul
beneath column D into the blank row just inserted. I've figured out ho
insert a blank row every fourth row, but I can't figure out how to ge
the numbers in column D to sum and be put in that blank row beneath it
Help?!?!
 
Assuming your target cell is activate, you could use:
ActiveCell.FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"
To insert a formula to add up the values in the preceding 4 rows.

Your macro will run faster, though, if it permits a target cell to be
referenced without selecting/activating it. For example:
Cells(i,4).FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"
where i is the inserted row number.

Cheers
 
Back
Top