Vlookup in a userform

Mad Moose

New Member
Joined
Jun 10, 2015
Messages
5
Hi All
I am stuck on what on the face of it seems a simple task but is proving frustrating
i am trying to enter a value from a table into a text box which corresponds to an entry in the previous column which I enter using a combobox with the vlookup vba function

any insight would be terrific

regards
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
This code doesnt seem to want to work when put in the combobox change bit


me.TextBox1 = Application.WorksheetFunction.VLookup((Me.ComboBox1), ("Table1"), 1, 0)
 
Upvote 0
If Table1 is a named range then use [Table1] instead of ("Table1").

This is working on my machine:
Code:
Private Sub ComboBox1_Change()
    Me.TextBox1.Value = Application.VLookup(Me.ComboBox1.Value, [Table1], 1, 0)
End Sub
 
Upvote 0
Thankyou
that worked a treat and I have been able to insert it into my project which has thrown up a new problem

instead of a textbox I have used a label no probs there but the data in the lable is a date and what shows is the numeriacal value and not the date

has anyone any suggestions as to how the date can be shown
do i have to code the label
 
Upvote 0
From support.Office.com
  1. Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900, is serial number 1, and January 1, 2008, is serial number 39448 because it is 39,448 days after January 1, 1900.

Use CDate(intVal) to convert it to date format.

Me.Label1.Caption = CDate(Application.VLookup(Me.ComboBox1.Value, [Table1], 2, 0))
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

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