View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default adding data to new column

Keyser,

See the macro below.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim Res As Integer
Dim myRng As Range

Set myRng = Range("A1")
Res = 1
myRng.Offset(0, Res + 1).EntireColumn.Insert

'How can I make cell (<NewCol33) have the value
'"=SUM(<newcol2:<newcol32)" ?
'ie: if the new column is Column C, I would like cell C33 to be
'"=SUM(C2:C32)"

Cells(33, myRng.Offset(0, Res + 1).Column).FormulaR1C1 = _
"=SUM(R[-31]C:R[-1]C)"

End Sub



wrote in message oups.com...
I am using this to insert a column:

myRng.Offset(0, Res + 1).EntireColumn.Insert

How can I make cell (<NewCol33) have the value
"=SUM(<newcol2:<newcol32)" ?

ie: if the new column is Column C, I would like cell C33 to be
"=SUM(C2:C32)"

Thanks!