Vlookup last price of product in userform

Ahmed Fawad

Board Regular
Joined
Mar 1, 2011
Messages
63
Office Version
  1. 2016
Platform
  1. Windows
Please guide....

I've got a userfrom for expense posting. I want it to do is when I add a product name in the description it shows the last purchase price in the other textbox and "Not Found" if it's a new product.

What I've done is

Private Sub txtdesc_Afterupdate()
With Me

txtlprice = Application.WorksheetFunction.VLookup(Me.txtdesc, Lists.Range("E:H"), 4, 0)

End With
End Sub

Error:
Run-time error '424':
Object required


TIA

Ahmed
 

Attachments

  • 1629154433571.png
    1629154433571.png
    17.7 KB · Views: 5

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Where is this in the workbook ? Do you have a sheet whose "codename" is Lists ?
Lists.Range("E:H")
 
Upvote 0
Where is this in the workbook ? Do you have a sheet whose "codename" is Lists ?
Lists.Range("E:H")
Yes, it's sheet's name Lists and details are like this

DescriptionAccountHeadRate
Adek Power PlusRana ImranMedicine1,700.00
Anti GhumboDMGMedicine1,520.00
AvilNaseem & CoMedicine40.00
Bio Liver ToneRana ImranMedicine2,300.00
Bio Ment PlusRana ImranMedicine4,500.00
Bio MultivitRana ImranMedicine2,100.00
BiosignRana ImranMedicine850.00
 
Upvote 0
Codename is different to sheet name. Your current syntax will only work if it was the codename and I don’t believe that is the case.
  • If you know it will be the active sheet put > Range("E:H")
  • If it is not the active sheet or you are not sure it will be put > Worksheets(“Lists”).Range("E:H")
Let me know if changing that fixes your issue.
 
Upvote 0
Solution
Codename is different to sheet name. Your current syntax will only work if it was the codename and I don’t believe that is the case.
  • If you know it will be the active sheet put > Range("E:H")
  • If it is not the active sheet or you are not sure it will be put > Worksheets(“Lists”).Range("E:H")
Let me know if changing that fixes your issue.
Worksheets(“Lists”).Range("E:H") ... Works great

thank you very much dear

Ahmed
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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