ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox Issue (https://www.excelbanter.com/excel-programming/335626-combobox-issue.html)

Andy

Combobox Issue
 
Hi,

I have a cell value in excel B6
I also have combobox1

What I would like to do is if B6 = "Number 1" then populate the combobox
with the text range C1:C3

If B6 = "Number 2" then populate the combobox with the text range D1:D3

Is this possible, if so can somebody please help???

Thanks for any help

Andy



Bob Phillips[_7_]

Combobox Issue
 
Is it a control toolbox combox?

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$6" Then
Select Case Target.Value
Case "Number 1": Me.ComboBox1.ListFillRange = "C1:C3"
Case "Number 2": Me.ComboBox1.ListFillRange = "D1:D3"
'etc
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"Andy" wrote in message
o.uk...
Hi,

I have a cell value in excel B6
I also have combobox1

What I would like to do is if B6 = "Number 1" then populate the combobox
with the text range C1:C3

If B6 = "Number 2" then populate the combobox with the text range D1:D3

Is this possible, if so can somebody please help???

Thanks for any help

Andy





Andy

Combobox Issue
 
Hi Bob,

That works exactly as I needed and it doesn't appear to matter that the
columns are hidden, Fantastic!
Many Thanks

Andy


"Bob Phillips" wrote in message
...
Is it a control toolbox combox?

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$6" Then
Select Case Target.Value
Case "Number 1": Me.ComboBox1.ListFillRange = "C1:C3"
Case "Number 2": Me.ComboBox1.ListFillRange = "D1:D3"
'etc
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"Andy" wrote in message
o.uk...
Hi,

I have a cell value in excel B6
I also have combobox1

What I would like to do is if B6 = "Number 1" then populate the combobox
with the text range C1:C3

If B6 = "Number 2" then populate the combobox with the text range D1:D3

Is this possible, if so can somebody please help???

Thanks for any help

Andy








All times are GMT +1. The time now is 12:22 PM.

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