User Form and VLookup

Buskopan

Board Regular
Joined
Aug 4, 2014
Messages
54
Helol Again!

Trying to understand how that works with userform.

I got combobox1 on user form which takes the names range from the list Database. I want textbox3 to vlookup for the positions. But getting the "424 object required error"

Range "POBALL" is 4 column.

What is wrong with the code ?

Code:
Private Sub UserForm_Initialize()
    Me.TextBox1 = Date
    Me.TextBox2 = Time
    Me.TextBox3.Value = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, Sheet2.Range("POBALL"), 3, False)
   
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

Issue is with the lookup range for Vlookup function. As you mentioned POBALL is column 4 only and you are looking for column number 3 in your formula. You cannot find 3rd column in a range which is limited to 1 column only.

Regards,
Shweta
 
Upvote 0
Sorry .Maybe I explained wrong.
Combobox1 range is Range named POBnames. Once userform loads it is empty, user have to chose from the list the name. And then I want textbox3 to show the company.

List Database have 2 ranges. 1 Range is POBnames which is only 1 column and another one is POBALL which is 4 colums. Name, company, position, roomN. Forget about date and time.

Lets say I want textbox3 to show the company once combobox1 value selected in userform.

Code:
Private Sub UserForm_Initialize()
    Me.TextBox3.Value = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, Sheets(Database).Range("POBALL"), 3, False)
End Sub

Why i'm getting Error 9 Subsript out of range ?
and
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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