nicklbailey
New Member
- Joined
- Apr 10, 2013
- Messages
- 3
I am trying to write a macro with a formula whose reference varies with the cell and have not been able to find any clear explanation of how this is done (my guess is it's really obvious and I am just not seeing it.
This is what I have now
I want the first formula to be "=MATCH(G1,H$1:H$291,0)" for K1, "=MATCH(G2,H$1:H$291,0)" for K2 and so forth.
Similarly the second formula should vary with the row.
Is there an easy way to do this?
Best
Nick
This is what I have now
Code:
Sub Test()
'
' Test Macro
'
'
Dim Row As Integer
For Row = 1 To 500
Dim RefCell As Range
Set RefCell = Cells(Row, 11)
RefCell.FormulaR1C1 = "=MATCH(RC[-4],H$1:H$291,0)"
Cells(Row, 12).FormulaR1C1 = "=INDEX(A1:M1000,VALUE(RC[-1]),9)"
Next Row
End Sub
I want the first formula to be "=MATCH(G1,H$1:H$291,0)" for K1, "=MATCH(G2,H$1:H$291,0)" for K2 and so forth.
Similarly the second formula should vary with the row.
Is there an easy way to do this?
Best
Nick