How to get row

dave8

Active Member
Joined
Jul 8, 2007
Messages
275
I have a vLookup routine that looks like this:


Code:
Function Customer_vlookup(Table_Rng As Range, Return_Col As Long, Col1_Fnd, Col2_Fnd)
Dim rCheck As Range, bFound As Boolean, lLoop As Long
Dim rowSet As Range
 
On Error Resume Next
Set rCheck = Table_Rng.Columns(1).Cells(1, 1)
 
With WorksheetFunction
For lLoop = 1 To .CountIf(Table_Rng.Columns(1), Col1_Fnd)
Set rCheck = Table_Rng.Columns(1).Find(Col1_Fnd, rCheck, xlValues, xlWhole, xlNext, xlRows, False)
' 
' I want to be able to select the row after item is found (Col1_Fnd)
' 
 
exit for
Next lLoop
End with


I'm able to find the value in Col1_Fnd, but I want to select the row that the value is in. For example, the lookup values are in A1:A26. If the value found (Col1_Fnd) is in A5, I want to be able to select this row.
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
From the looks of what you have posted, I would think all you would need to do is return the Row property of the rCheck variable (assuming it found an entry). Such as rCheck.Row.Select

However in theory a worksheet function shouldn't be select anything. If you want to return the row number as the result, you could rework your code to display the row number as the result (rCheck.Row), try an Index/Match function instead of Vlookup or simply rewrite the code to run your above code as a macro and not a worksheet function by say assigning the macro to a button somewhere.
 
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,261
Members
449,307
Latest member
Andile

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