Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Formula VS Formula R1C1

Hi all
Please point when to use each (using VBA...)
TIA
Guy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Formula VS Formula R1C1

Most of the time you would use Formula.
But if for example you write a UDF that displays the formula of a cell, you
might want to display it in the adressing style that is used in the
workbook. So then you test to see what adressing style was used and choose
between Formula and FormulaR1C1. Possibly also between Formula and
FormulaLocal (and the R1C1 option of Local).
Same when you use text from the worksheet to construct a formula and write
that to a cell.

--
Kind regards,

Niek Otten

Microsoft MVP - Excel

"Joe" wrote in message
...
Hi all
Please point when to use each (using VBA...)
TIA
Guy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Formula VS Formula R1C1

Firstly, Formula and FormulaR1C1 should only be used when creating a
formula, it is not necessary just to set a value, Value is good enough for
that.

Formula is best used when you want to set up a relatively straight-forward
formula using A1 notation, such as =SUM(A1:A10), or
=VLOOKUP(A1,M1:O20,2,False), and you know that the referenced cells are
locked in position, that is row or column insertion and deletion does not
move the formula references. If this happens, it is much harder to set the
formula using A1 notation trying to determine the column letter relative to
a know point (such as the cell containing the formula).

If the formula could be added at various points, and you want to reference a
point relative to a known point, I think R1C1 notation is simpler. For
instance, creating a formula of adding 3 cells to the right is simply done
with activecell.FormulaR1C1 = "=SUM(RC[+1]:RC[+3])", which is a tad more
difficult with A1 notation. Using variables, for say the row number is also
easy in this style, activecell.FormulaR1C1 = "=SUM(R" & iRow & "C[+1]:R" &
iRow + 2 & "C[+3])" where iRow contains a start row number.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Joe" wrote in message
...
Hi all
Please point when to use each (using VBA...)
TIA
Guy




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Formula VS Formula R1C1

Bob wrote:
Formula is best used when you want to set up a relatively straight-forward
formula using A1 notation, such as =SUM(A1:A10), or
=VLOOKUP(A1,M1:O20,2,False), and you know that the referenced cells are
locked in position, that is row or column insertion and deletion does not
move the formula references. If this happens, it is much harder to set the
formula using A1 notation trying to determine the column letter relative to
a know point (such as the cell containing the formula).


A cool workaround for this is using a named range which Excel keeps track of
wherever it may have moved to on the worksheet. For example you select A1:C3
(a 9 cell block) and give it a Name in the menu Insert/Name/Define something
like "Formulas_A". That 9-cell block now becomes a miniature spreadsheet.
Just like the regular worksheet, you can now refer to cells within the named
range in A1 notation. The upper left cell will always be A1 and the lower
right cell will always be C3, within that range, and wherever that range is
on the worsheet, as long as that range is kept intact with the original 9
cells and not broken up.
In VBA you would use the .Range.Range method to address the cells within the
named range in A1 notation. For example:

Sheets("Sheet1").Range("Formulas_A").Range("A1:C3" ).Value = "0"

That would make all 9 cells display "0". If the named range "Formulas_A" had
been moved so the upper left corner is on H7, then H7:J9 will be 0's.
An example of R1C1 would be:

Sheets("Sheet1").Range("Formulas_A")(3, 3).Value = "0"

This would only make J9 =0

The following would put a formula in H7:

Range("Formulas_A").Range("A1").Formula = "=IF(AND(A2=A3,B3=""Y""),1,0)"

Is this making sense to you?
Mike F



"Joe" wrote in message
...
Hi all
Please point when to use each (using VBA...)
TIA
Guy



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
R1C1 formula question igorek Excel Worksheet Functions 2 October 5th 07 02:58 AM
R1C1 Formula in Excel Barb Reinhardt Excel Worksheet Functions 2 December 8th 05 02:40 PM
using variables in formula in R1C1 mode domin Excel Programming 10 March 22nd 05 12:04 AM
Variable in an R1C1 formula kptheop Excel Programming 1 October 23rd 04 12:18 AM
looping formula - r1c1 problem MDC[_2_] Excel Programming 2 October 22nd 03 11:13 PM


All times are GMT +1. The time now is 11:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"