how to select dynamic row in vlookup

Ron_N

New Member
Joined
Aug 25, 2011
Messages
30
Hi,

i am using the following formula to get the value of 'vt'.
-------------------------------------------------------
'i have used autofilter. So my range keeps changing.

Set rCell = Range("A1").CurrentRegion
Set rCell = rCell.Offset(1, 0).Resize(rCell.Rows.Count - 1, rCell.Columns.Count)

rCell(1,1).Select ' to select the first cell after applying autofilter

vt = Application.WorksheetFunction.Vlookup(Cells(2, 4).Value, VarRateTable, 2, 0)
-------------------------------------------------------
But i want the row number to be dynamic, the row number should take the address from rcell(1,1) and the column to be the 4th column(fixed). Please tell me how to do it.

Thanks
Ron
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Untested, but try
Code:
Set rCell = Range("A1").CurrentRegion
Set rCell = rCell.Offset(1, 0).Resize(rCell.Rows.Count - 1, rCell.Columns.Count)

rCell(1,1).Select ' to select the first cell after applying autofilter

vt = Application.WorksheetFunction.Vlookup(Cells(rCell.Row, 4).Value, VarRateTable, 2, 0)
 
Upvote 0
Hi Thompson,

i tried the code suggested by you. It runs fine the first time. But after the iteration of autofilter, suppose the first visible cell is A5. Even then this code is still picking up A2 as the row while applying vlookup.I want rcell as the chosen row in the lookup formula.
Please tell me where i am going wrong.

Thanks,
Ron
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,741
Members
452,940
Latest member
rootytrip

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