Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Relative references in formulas

I am aware of the basic usage of relative references in establishing a
formula. For example to sum a column of cells relative to a given cell the
following can be used:
ActiveCell.FormulaR1C1="=sum(R[-5]C[-2]:R[-1]C[-2])"
However, since the formula is a string, it is not possible to replace, for
instance, -5 with a variable. Is there a straightforward way to do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Relative references in formulas


Dim myVar as double 'your variable

MyVar = -5

ActiveCell.FormulaR1C1="=sum(R[" & myVar & "]C[-2]:R[-1]C[-2])"

"VegasPines" wrote:

I am aware of the basic usage of relative references in establishing a
formula. For example to sum a column of cells relative to a given cell the
following can be used:
ActiveCell.FormulaR1C1="=sum(R[-5]C[-2]:R[-1]C[-2])"
However, since the formula is a string, it is not possible to replace, for
instance, -5 with a variable. Is there a straightforward way to do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Relative references in formulas

ker_01,

Thanks very much. That works just fine. It's great to know there is this
kind of help available since getting the same kind of help from the Microsoft
help function seems to be impossible. Either I don't know how to ask the
question or it is really that difficult.

VegasPines
--
VegasPines


"ker_01" wrote:


Dim myVar as double 'your variable

MyVar = -5

ActiveCell.FormulaR1C1="=sum(R[" & myVar & "]C[-2]:R[-1]C[-2])"

"VegasPines" wrote:

I am aware of the basic usage of relative references in establishing a
formula. For example to sum a column of cells relative to a given cell the
following can be used:
ActiveCell.FormulaR1C1="=sum(R[-5]C[-2]:R[-1]C[-2])"
However, since the formula is a string, it is not possible to replace, for
instance, -5 with a variable. Is there a straightforward way to do this?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Relative references in formulas

Conceptually compared to a database language programming the relativity thing
takes a bit of getting used to. And given the very nature of spreadsheets and
that you can add or delete Rows or Columns in an instance that means that
anything to do with range definItions in VBA can take some effort. It
therefore amazes me that so many of the examples in the Help files only use
"A1:D5" style notation rather than more useful relational referencing.

--
Ken
"Using Dbase dialects since 82"
"Started with Visicalc in the same year"


"VegasPines" wrote:

ker_01,

Thanks very much. That works just fine. It's great to know there is this
kind of help available since getting the same kind of help from the Microsoft
help function seems to be impossible. Either I don't know how to ask the
question or it is really that difficult.

VegasPines
--
VegasPines


"ker_01" wrote:


Dim myVar as double 'your variable

MyVar = -5

ActiveCell.FormulaR1C1="=sum(R[" & myVar & "]C[-2]:R[-1]C[-2])"

"VegasPines" wrote:

I am aware of the basic usage of relative references in establishing a
formula. For example to sum a column of cells relative to a given cell the
following can be used:
ActiveCell.FormulaR1C1="=sum(R[-5]C[-2]:R[-1]C[-2])"
However, since the formula is a string, it is not possible to replace, for
instance, -5 with a variable. Is there a straightforward way to do this?

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
Copying formulas with relative references Carl Excel Discussion (Misc queries) 2 March 24th 08 07:00 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
Copying formulas, relative and absolute cell references Garnet Excel Discussion (Misc queries) 3 February 22nd 07 08:51 AM
Named formulas in CHOOSE need to be Relative references when paste bill ch Excel Worksheet Functions 2 April 10th 06 04:13 PM
Confused about relative references in named formulas [email protected] Excel Worksheet Functions 1 March 22nd 06 10:40 PM


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