ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   one combobox affecting another (https://www.excelbanter.com/excel-programming/407679-one-combobox-affecting-another.html)

JohnP

one combobox affecting another
 
Hi,
I have 2 comboboxes ("Business" and "Name"). When Business is selected I
would like Name to populate with all the names on the sheet that is named
Business.

I have tried the following code but get an error message saying that Name is
an invalid qualifier. Can you change one comobox with another or is my code
just flawed?

Private Sub Business_Change()

Sheets("" & Business).Select
Range("E7").Activate
While ActiveCell < ""
Name.AddItem ActiveCell.Value
ActiveCell.Offset(0, 1).Activate
Wend

End Sub

Thanks for any help you can offer.
JohnP

joel

one combobox affecting another
 
You can't name the userform NAME it is a reserved word in Basic. change it
to MName. You can still have the caption called Name. also you need to put
double quotes around the sheet name business unless it is a variable.

Private Sub Business_Change()
Sheets("Business").Select
Range("E7").Activate
While ActiveCell < ""
UserForm1.MName.AddItem ActiveCell.Value
ActiveCell.Offset(0, 1).Activate
Wend

End Sub


"JohnP" wrote:

Hi,
I have 2 comboboxes ("Business" and "Name"). When Business is selected I
would like Name to populate with all the names on the sheet that is named
Business.

I have tried the following code but get an error message saying that Name is
an invalid qualifier. Can you change one comobox with another or is my code
just flawed?

Private Sub Business_Change()

Sheets("" & Business).Select
Range("E7").Activate
While ActiveCell < ""
Name.AddItem ActiveCell.Value
ActiveCell.Offset(0, 1).Activate
Wend

End Sub

Thanks for any help you can offer.
JohnP



All times are GMT +1. The time now is 06:26 AM.

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