ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   refresh combobox (https://www.excelbanter.com/excel-programming/420030-refresh-combobox.html)

Mel

refresh combobox
 
hi guys,

pretty new to the programming of excel and would like to ask bout this
question.

Here's what i have done so far:

i have a two comboboxes (i.e. ComboBox A and B)
say i have a few values in ComboBoxA and when a user selects a certain
value, ComboBoxB would change it's ListFillRange according to the value
selected in ComboBoxA. However, the values in ComboBoxB would not update
itself unless i manually change the values in ComboBoxB.
anyone can help me in terms of how to refresh the ListFillRange in ComboBoxB
when a selection in ComboBoxA is changed?


my code:

Private Sub ComboBox2_Change()

If ComboBox1.Value = "A" Then
ComboBox2.ListFillRange = "AList"

Else
ComboBox2.ListFillRange = "BList"

End If

End Sub



Thanks in Advance,

Melvin

Per Jessen

refresh combobox
 
Hello Melvin

As you change the value of ComboBox A, you need to use the event code for
ComboBox 1 not ComboBox 2.

Private Sub ComboBox1_Change()

If ComboBox1.Value = "A" Then
ComboBox2.ListFillRange = "AList"
Else
ComboBox2.ListFillRange = "BList"
End If
me.Repaint
End Sub

Regards,
Per

"mEl" skrev i meddelelsen
...
hi guys,

pretty new to the programming of excel and would like to ask bout this
question.

Here's what i have done so far:

i have a two comboboxes (i.e. ComboBox A and B)
say i have a few values in ComboBoxA and when a user selects a certain
value, ComboBoxB would change it's ListFillRange according to the value
selected in ComboBoxA. However, the values in ComboBoxB would not update
itself unless i manually change the values in ComboBoxB.
anyone can help me in terms of how to refresh the ListFillRange in
ComboBoxB
when a selection in ComboBoxA is changed?


my code:

Private Sub ComboBox2_Change()

If ComboBox1.Value = "A" Then
ComboBox2.ListFillRange = "AList"

Else
ComboBox2.ListFillRange = "BList"

End If

End Sub



Thanks in Advance,

Melvin



Mel

refresh combobox
 
Hey thanks buddy!

it worked!

Melvin

"Per Jessen" wrote:

Hello Melvin

As you change the value of ComboBox A, you need to use the event code for
ComboBox 1 not ComboBox 2.

Private Sub ComboBox1_Change()

If ComboBox1.Value = "A" Then
ComboBox2.ListFillRange = "AList"
Else
ComboBox2.ListFillRange = "BList"
End If
me.Repaint
End Sub

Regards,
Per

"mEl" skrev i meddelelsen
...
hi guys,

pretty new to the programming of excel and would like to ask bout this
question.

Here's what i have done so far:

i have a two comboboxes (i.e. ComboBox A and B)
say i have a few values in ComboBoxA and when a user selects a certain
value, ComboBoxB would change it's ListFillRange according to the value
selected in ComboBoxA. However, the values in ComboBoxB would not update
itself unless i manually change the values in ComboBoxB.
anyone can help me in terms of how to refresh the ListFillRange in
ComboBoxB
when a selection in ComboBoxA is changed?


my code:

Private Sub ComboBox2_Change()

If ComboBox1.Value = "A" Then
ComboBox2.ListFillRange = "AList"

Else
ComboBox2.ListFillRange = "BList"

End If

End Sub



Thanks in Advance,

Melvin





All times are GMT +1. The time now is 05:21 PM.

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