Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to use/evaluate another Cell Formula in R1C1 style

I am trying to create a formula to evaluate another cell formula from the
formula caller cell address.
Supose a have
a b
1 10 30
2 20 40
3 =A1+A2 =udfEvaluate(A3)

the user-defined-formula udfEvaluate should retieve B1+B2=70, i.e., A3 cell
formula evaluated from its perspective = R[-2]C+R[-1]C

P.S. The real formula is huge and does not fit in name-defined.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default How to use/evaluate another Cell Formula in R1C1 style

Function udfEvaluate(ByRef rng As Range)
Dim sF1 As String
Dim iRow As Long
Dim iColumn As Long
With Application
iRow = rng.Row
iColumn = rng.Column
sF1 = .Substitute(rng.Offset(0, -1).Formula, "ROW()", iRow)
sF1 = .Substitute(sF1, "COLUMN()", iColumn)
sF1 = .ConvertFormula(sF1, xlA1, xlR1C1)
sF1 = .ConvertFormula(sF1, xlR1C1, xlA1, , rng)
End With
udfEvaluate = rng.Parent.Evaluate(sF1)
End Function


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Caio Milani" <Caio wrote in message
...
I am trying to create a formula to evaluate another cell formula from the
formula caller cell address.
Supose a have
a b
1 10 30
2 20 40
3 =A1+A2 =udfEvaluate(A3)

the user-defined-formula udfEvaluate should retieve B1+B2=70, i.e., A3

cell
formula evaluated from its perspective = R[-2]C+R[-1]C

P.S. The real formula is huge and does not fit in name-defined.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to use/evaluate another Cell Formula in R1C1 style

Thanks Bob, I just removed the offset(0,-1) and its is working fine.

"Bob Phillips" escreveu:

Function udfEvaluate(ByRef rng As Range)
Dim sF1 As String
Dim iRow As Long
Dim iColumn As Long
With Application
iRow = rng.Row
iColumn = rng.Column
sF1 = .Substitute(rng.Offset(0, -1).Formula, "ROW()", iRow)
sF1 = .Substitute(sF1, "COLUMN()", iColumn)
sF1 = .ConvertFormula(sF1, xlA1, xlR1C1)
sF1 = .ConvertFormula(sF1, xlR1C1, xlA1, , rng)
End With
udfEvaluate = rng.Parent.Evaluate(sF1)
End Function


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Caio Milani" <Caio wrote in message
...
I am trying to create a formula to evaluate another cell formula from the
formula caller cell address.
Supose a have
a b
1 10 30
2 20 40
3 =A1+A2 =udfEvaluate(A3)

the user-defined-formula udfEvaluate should retieve B1+B2=70, i.e., A3

cell
formula evaluated from its perspective = R[-2]C+R[-1]C

P.S. The real formula is huge and does not fit in name-defined.




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
Using INDIRECT & R1C1 Ref style Bassman62 Excel Worksheet Functions 5 November 5th 08 09:38 PM
R1C1 reference style Helpme Please[_2_] Excel Discussion (Misc queries) 5 July 11th 07 11:12 PM
How do I change sheet notation from R1C1 style to A1 style in XL 2 Sherlock1506 Setting up and Configuration of Excel 1 December 5th 06 03:22 PM
can a1 reference style and r1c1 style be used in same formula? rjagga Excel Worksheet Functions 1 September 17th 06 10:58 AM
R1C1 reference style Peg P Excel Discussion (Misc queries) 2 November 15th 05 06:48 PM


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