Vlookup Loop

Sundae

New Member
Joined
Jul 25, 2011
Messages
44
Hi All,

I have the following code that works fine on returning the value for cell B20, but that is not what I need:

Sub Test_Lookup()
Dim rngRequested As Range, rng As Range
Set rngRequested = Sheets("Role").Range("C23")
Set rng = Workbooks("Data.xlsx").Worksheets("Earl").Range("Wager")
rngRequested.Value = ""
Dim res As Variant
Dim errNum As Integer

On Error Resume Next
res = Application.WorksheetFunction.VLookup(Sheets("Role").Range("B20"), rng, 2, 0)

errNum = Err.Number
If errNum <> 0 Then
res = "Error: " & errNum
End If
rngRequested.Value = res
End Sub
************

What I would like to happen is if Column A = "DRAKE" then find ("B & x" &"*" * Range (DPT) in another workbook DATA, Range Wager.

The reason I have to do the find DRAKE is because the lookup field is every 5th row.

Also, this will be a loop within a loop, as I have additional code that will copy and paste this range a specified # of times.

Thanks for any help!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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