Sum new Column Added

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have Excell XP 2002, I have a macro that inserts two columns one is a date
field and one is a number field.

After inserting the number column I would like to have a macro to place a
sum formula in row 27 of the column. Any ideals.

I have tried a couple others that have been offered, and nothing seems to be
working.
 
try using the macro recorder. turn it on, then
insert column
write your sum formula in row 27
turn off macro recorder.

the resulting macro code should give you a pretty good place to start
- you could probably just copy & paste that code into your current
macro.
:)
susan
 
try
Sub insertcolumnsandsum()
ac = ActiveCell.Column
ar = 1
With Cells(ar, ac)
.Resize(, 2).EntireColumn.Insert
.Offset(27, 0).Formula = _
"=sum(r1c" & ac + 2 & ":r27c" & ac + 2 & " )"
End With
End Sub
 
assume the first column is Date and the second is the values to be summed.

icol = 10
Columns(icol).Resize(,2).Insert
cells(27,icol + 1).Formula = "=Sum(K1:K26)"


Change the 10 to the column number of the new column which will be the date
column.
 
Forgot to change the address in the formula when I decided to generalize the
macro.

cells(27,icol + 1).Formula = "=Sum(K1:K26)"
should be

cells(27,icol + 1).FormulaR1C1 = "=Sum(R1C:R26C)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top