Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default "=sum(variable:variable2)"

I would like to put this formula into a specific cell. Here is my code:
for Counter 1 to 20
Cells((OneWkRow + 8), Counter).Value = "=Sum(c1_right_1 : c_right_1)"
Next Counter

Why is this not working? Can I not use variables in this instance? How can
I make this work? Thanks!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default "=sum(variable:variable2)"

Everything between " and " is treated as a string. Try something like

Cells((OneWkRow + 8), Counter).Value = _
"=Sum(" & c1_right_1 &":" & c_right_1 & ")"

HTH
Rowan

"KyWilde" wrote:

I would like to put this formula into a specific cell. Here is my code:
for Counter 1 to 20
Cells((OneWkRow + 8), Counter).Value = "=Sum(c1_right_1 : c_right_1)"
Next Counter

Why is this not working? Can I not use variables in this instance? How can
I make this work? Thanks!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default "=sum(variable:variable2)"

You have 20 columns starting at A.
You have 7 days data - in my example these are rows 5 to 11 , so OneWkStart
is set to row 5
In the next row, row 12, you want to add the values in the columns for the
week?

Try this as an alternative

Sub Demo()
Dim OneWkRow As Long
OneWkRow = 5

With Range(Cells(OneWkRow + 7, 1), Cells(OneWkRow + 7, 20))
.FormulaR1C1 = "=Sum(R[-8]C:R[-1]C)"
End With

End Sub



"KyWilde" wrote:

I would like to put this formula into a specific cell. Here is my code:
for Counter 1 to 20
Cells((OneWkRow + 8), Counter).Value = "=Sum(c1_right_1 : c_right_1)"
Next Counter

Why is this not working? Can I not use variables in this instance? How can
I make this work? 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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
reading variable "from" and "to" ZIP codes Dan Wasser[_2_] Excel Programming 2 January 9th 04 01:36 PM


All times are GMT +1. The time now is 09:45 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"