Vlookup Lookup value help in Vba

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
hey Guys, so I am trying to automate this report using macros, and When I come to use vlookup, it puts the code as ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-12],References[#All],2,0)"

This works for one of my sheets, but it wont work for all of them as new columns will be added with each update. is there a way for it to reference the cell "$A2" every time instead of me having to re write a code calculating how many rows and columns away it is.

I also tried putting in R2C1 instead of the RC[-12] but that fixes the references. I need it to be $A2, not $A$2

any and all help would be greatly appreciated!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,823
Messages
6,181,179
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