PC Review


Reply
Thread Tools Rate Thread

cell referencing with variables

 
 
=?Utf-8?B?TGllc2JldGg=?=
Guest
Posts: n/a
 
      8th Mar 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      8th Mar 2007
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 With Quote
 
=?Utf-8?B?TGllc2ll?=
Guest
Posts: n/a
 
      9th Mar 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a cell in another sheet through the use of variables JJ Microsoft Excel Programming 2 3rd Dec 2009 11:36 PM
Problem referencing a cell using 2 variables akbnsl@gmail.com Microsoft Excel Programming 1 8th Aug 2008 11:45 AM
referencing with variables mpele Microsoft Excel Programming 1 8th Mar 2006 10:22 AM
Referencing Variables =?Utf-8?B?RHdpbm1hYw==?= Microsoft Excel Worksheet Functions 1 16th Nov 2004 06:18 PM
referencing variables PLEASE HELP ME! name Microsoft C# .NET 5 18th Jan 2004 03:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:55 AM.