Vlookup - vba - data validation list

scottie_72

Board Regular
Joined
Mar 6, 2014
Messages
50
Hi There.. (Again!)

I have three columns (C D E)

> Column C: Has Data validation list
> Column D: Is where I want the VLookup formula (in code) to retrieve the relevant info.
> Column E: Has a Quantity Value (Not really relevant as this is a manual entry)

I have done the below code - now it works but not automatically - If I put this in a Worksheet _Change procedure it comes up with an error - and also it doesn't work if cell "C" is blank.

Code:
Sub VLookup()


Dim ws As Worksheet, lRow As Long, moreInfo as Variant


Set ws = Sheets("OrderForm")
lRow = ws.Cells(Rows.Count, 3).End(xlUp).Row
moreInfo = ws.Range("D" & lRow)


With ws
moreInfo = Application.WorksheetFunction.VLookup(Range("C" & lRow), Range("P_Table"), 2, 0)
.Range("D" & lRow).Value = moreInfo
End With
End Sub

Can anybody please help as its been driving me mad for a couple of days now!

Many Thanks in Advance
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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