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
 

Some videos you may like

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.

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,328
Members
414,054
Latest member
Sameer50

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
Top