Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default adding data to new column

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default adding data to new column

Great!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default adding data to new column

I condensed it down to:

myRng(33, 2).FormulaR1C1 = "=SUM(R[-31]c:r[-1]c)"

Now I would like to add the formula : =IF(<Col1<"",<Col1&"
comments","") is an earlier column in the sheet.
I tried:


myRng(1, Res + 2).FormulaR1C1 = "=IF(C[-Res]<"""",C[-Res]&""
comments"","""") "

but this bombs. Can you tell me what the correct format of the formula
should be in this macro?

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default adding data to new column

keyser,

ActiveCell.FormulaR1C1 = _
"=IF(RC[" & -res & "]<"""",RC[" & -res & "]&"" comments"","""")"

HTH,
Bernie
MS Excel MVP


wrote in message
oups.com...
I condensed it down to:

myRng(33, 2).FormulaR1C1 = "=SUM(R[-31]c:r[-1]c)"

Now I would like to add the formula : =IF(<Col1<"",<Col1&"
comments","") is an earlier column in the sheet.
I tried:


myRng(1, Res + 2).FormulaR1C1 = "=IF(C[-Res]<"""",C[-Res]&""
comments"","""") "

but this bombs. Can you tell me what the correct format of the formula
should be in this macro?

Thanks.



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
Adding digits in a column based on data in a separate column adriver Excel Discussion (Misc queries) 4 April 21st 10 12:41 AM
Adding column data based on match in 2nd column - Help GBExcel via OfficeKB.com Excel Worksheet Functions 3 January 26th 10 05:58 PM
Removing one column of data and adding another column Rodders Excel Discussion (Misc queries) 1 August 26th 09 08:25 AM
Adding data to existing data that has a unique number in column Lars Excel Discussion (Misc queries) 3 June 28th 07 11:48 AM
Adding column data stge Excel Worksheet Functions 1 November 4th 04 07:19 PM


All times are GMT +1. The time now is 06:43 PM.

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"