ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform - ComboBox fills TextBox not working (https://www.excelbanter.com/excel-programming/332425-userform-combobox-fills-textbox-not-working.html)

thom hoyle

Userform - ComboBox fills TextBox not working
 
Thanks for looking at this.
Form Data:
I have a multipage userform. On page 3, I have a dropdown combobox called
cboAtty that autofills from ROWSOURSE properties =Data!A2:A30 (Sheet Data).
This part works fine.
Also, located on the same form is a TexBox called tbBar:

Data:
On another sheet called Data I have the same info as A2:A30, then in B2:B30
a number associated to each A column data.
Now Back to the Combo Box called cboAtty, I have the following Code that
fails with the message.
Run-time error '-2147352571 (80020005)':
Could not set the Value property. Type mismatch

Private Sub cboAtty_Change()
tbBar.Value = Application.VLookup _
(cboAtty.Value, Sheet1.Range("A2:B30"), 2, False)
End Sub

My Objective is to have the TextBox tbBar to autofill based on my selection
of the DropDown ComboBox called cboAtty.
Thanks


Toppers

Userform - ComboBox fills TextBox not working
 
Thom,

I emulated your code and it worked fine for me (in a single and multi-page
userform).

In your note to say the RowSource is in a sheet named Data and then further
on you say there is another sheet named Data - I was slightly confused by
this. In my testing I used the same A2:A30 for both RowSource and VLOOKUP.

I note you reference Sheet1 in you VLOOKUP -is this correct? Should it (does
it) reference the sheet Data?

Your error message suggests (to me) a data mismatch.

Sorry I can't be more helpful.


"thom hoyle" wrote:

Thanks for looking at this.
Form Data:
I have a multipage userform. On page 3, I have a dropdown combobox called
cboAtty that autofills from ROWSOURSE properties =Data!A2:A30 (Sheet Data).
This part works fine.
Also, located on the same form is a TexBox called tbBar:

Data:
On another sheet called Data I have the same info as A2:A30, then in B2:B30
a number associated to each A column data.
Now Back to the Combo Box called cboAtty, I have the following Code that
fails with the message.
Run-time error '-2147352571 (80020005)':
Could not set the Value property. Type mismatch

Private Sub cboAtty_Change()
tbBar.Value = Application.VLookup _
(cboAtty.Value, Sheet1.Range("A2:B30"), 2, False)
End Sub

My Objective is to have the TextBox tbBar to autofill based on my selection
of the DropDown ComboBox called cboAtty.
Thanks



All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com