Using R1C1 in .WorksheetFunction

brans1982

Active Member
Joined
Mar 25, 2009
Messages
263
Hi,

I'm using an index/match formula as below...

(wf = WorksheetFucntion)

Cells(2, 3).Resize(FinalRow - 1, 1) = _
wf.Index(Range("Routing"), wf.Match(Range("B2"), Range("Flight"), 0))


How do I turn Range("B2") into RC[-1] with in a WorksheetFunction? I can't get the syntax right. I know I can do this formula another way but would like to figure this out for future reference.

Thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You are not entering a formula into a cell, and are not using cell references. You are putting a VBA object ( Range Value ) into a worksheet function call. You can't use R1C1 referencing as a parameter into a Range property. If you need to access a range by row and column numbers you already know how to do that ... Cells(row,col ).
 
Upvote 0
You are not entering a formula into a cell, and are not using cell references. You are putting a VBA object ( Range Value ) into a worksheet function call. You can't use R1C1 referencing as a parameter into a Range property. If you need to access a range by row and column numbers you already know how to do that ... Cells(row,col ).

Thanks Glenn.

I was just trying to avoid looping a formula as there is over 10,000 rows and also, I want to get out of the habbit of entering a cell forumla and then copying and pasting the values.

What would you use?
 
Upvote 0
Would somethign on the lines of

Rich (BB code):
Cells(2, 3).Resize(FinalRow - 1, 1) _
= Evaluate("INDEX(Routing,MATCH(INDIRECT(""RC[-1]"",0),FLIGHT,0))")

work?

I'm not sure how the use of Evaluate would affect the outcome.
 
Upvote 0
while you could:
Code:
With Cells(2, 3).Resize(FinalRow - 1, 1)
.FormulaR1C1 = "=INDEX(Routing,MATCH(RC[-1], Flight, 0))"
.Value = .Value
End With
I have learnt from experience that sometimes the .value = .value is executed before the cells have completely recalculated - especially if there are sheet change events going on too. There is something you can use to ensure that calculation is complete before continuing, but I forget what it is.
I found in the end, that looping was a cleaner answer, 10,000 not really being a great deal:
Code:
For Each cll In Cells(2, 3).Resize(FinalRow - 1, 1).Cells
cll.Value = wf.Index(Range("Routing"), wf.Match(cll.Offset(, -1), Range("Flight"), 0))
Next cll
jasonb75, I tried yours:
Code:
Cells(2, 3).Resize(FinalRow - 1, 1) = Application.Evaluate("INDEX(routing,MATCH(INDIRECT(""RC[-1]"",0),flight,0))")
but got #REF! throughout the range.
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top