Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default cell referencing with variables

I need some help. I need to populate a formula where the rows and columns
are variable.

My first formula works. My second formula gets hung up on the variable "x".
Note ColumnNumbers 1 and 2 always change, but never less than 3 and 5
respectively, x is always columnnumber1 + 1

Cells(i, ColumnNumber1).FormulaR1C1 = "=SUM(RC2:RC[-1])"
' Cells(i, ColumnNumber2).FormulaR1C1 = "=SUM(RC[-x]:RC[-1])"

Is there another way of doing this formula? I am fairly new at VBA.

Thank you,
Liesbeth
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default cell referencing with variables

Assuming the value of x is being set somewhere else in the code,

Cells(i, ColumnNumber2).FormulaR1C1 = "=SUM(RC[-" & x & "]:RC[-1])"


"Liesbeth" wrote:

I need some help. I need to populate a formula where the rows and columns
are variable.

My first formula works. My second formula gets hung up on the variable "x".
Note ColumnNumbers 1 and 2 always change, but never less than 3 and 5
respectively, x is always columnnumber1 + 1

Cells(i, ColumnNumber1).FormulaR1C1 = "=SUM(RC2:RC[-1])"
' Cells(i, ColumnNumber2).FormulaR1C1 = "=SUM(RC[-x]:RC[-1])"

Is there another way of doing this formula? I am fairly new at VBA.

Thank you,
Liesbeth

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default cell referencing with variables

Thank you!

"Vergel Adriano" wrote:

Assuming the value of x is being set somewhere else in the code,

Cells(i, ColumnNumber2).FormulaR1C1 = "=SUM(RC[-" & x & "]:RC[-1])"


"Liesbeth" wrote:

I need some help. I need to populate a formula where the rows and columns
are variable.

My first formula works. My second formula gets hung up on the variable "x".
Note ColumnNumbers 1 and 2 always change, but never less than 3 and 5
respectively, x is always columnnumber1 + 1

Cells(i, ColumnNumber1).FormulaR1C1 = "=SUM(RC2:RC[-1])"
' Cells(i, ColumnNumber2).FormulaR1C1 = "=SUM(RC[-x]:RC[-1])"

Is there another way of doing this formula? I am fairly new at VBA.

Thank you,
Liesbeth

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
Help! Need to lookup referencing 2 variables I M Desperate!!! Excel Worksheet Functions 3 June 17th 08 02:14 AM
referencing a value from a chart with 3 variables KP@RG New Users to Excel 1 December 12th 06 02:29 PM
Referencing Controls Using Variables Teodomiro[_3_] Excel Programming 4 April 28th 06 06:21 PM
referencing with variables mpele Excel Programming 1 March 8th 06 10:22 AM
Referencing Variables Dwinmac Excel Worksheet Functions 1 November 16th 04 06:18 PM


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