VBA Absolute reference based on A1

bobaol

Board Regular
Joined
Jun 3, 2002
Messages
225
Office Version
  1. 365
  2. 2003 or older
Platform
  1. Windows
Hello, I need to use the value in A1 as my absolute reference. here is the formula in the cell =INDEX($A$36907:$BBW$999999,MATCH(TRIM(AH2),$A$36907:$A$999999,0),1) when i record it, the formula becomes this:
Selection.FormulaR1C1 = "=INDEX(R36907C1:R999999C1427,MATCH(TRIM(RC[-6]),R36907C1:R999999C1,0),1)" I have a value in cell A1 that changes depending on the day. I tried changing it to this, Selection.FormulaR1C1 = "=INDEX(R&range("a1")&C1:R999999C1427,MATCH(TRIM(RC[-6]),R&range("a1")&C1:R999999C1,0),1)" but it does not work. Any help is appreciated. thanks in advance.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You can remove the Selection.FormulaR1C1 and replace it with Selection.Formula, then replace the macro formula with the excel one.
VBA Code:
Selection.Formula = "=INDEX($A$36907:$BBW$999999,MATCH(TRIM(AH2),$A$36907:$A$999999,0),1)"
This has to be done manually after you record a macro.
 
Upvote 0
Alternatively, where you have (for example)
VBA Code:
R&range("a1")&C

replace with
Rich (BB code):
R" & [a1] & "C

Note the quotation marks.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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