PDA

View Full Version : Based on combobox key word - toogle visibility of other Comboboxes



CraigP
03-31-2019, 04:49 AM
Hi,
In Word 2013 - I'm trying to find a key word in a Combobox then based on the outcome, toggling the visibility of others...trying this code...no good...help! Thank you.

Private Sub ComboBox4_Change()
If Me.ComboBox4.Value <> "Unintentional" Then
Me.ComboBox5.Visible = False
Me.ComboBox6.Visible = False
Me.ComboBox7.Visible = False
Me.ComboBox8.Visible = False
Me.ComboBox9.Visible = False
Me.ComboBox10.Visible = False
Else
Me.ComboBox5.Visible = True
Me.ComboBox6.Visible = True
Me.ComboBox7.Visible = True
Me.ComboBox8.Visible = True
Me.ComboBox9.Visible = True
Me.ComboBox10.Visible = True
End If
End Sub

gmaxey
03-31-2019, 06:55 AM
Seems to be fine here:


Private Sub ComboBox1_Change()
If ComboBox1.Value <> "Unintentional" Then
ComboBox2.Visible = False
ComboBox3.Visible = False
ComboBox4.Visible = False
Else
ComboBox2.Visible = True
ComboBox3.Visible = True
ComboBox4.Visible = True
End If
End Sub

Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "A"
.AddItem "b"
.AddItem "Unintentional"
End With
End Sub

Are you triggering the event?

CraigP
04-01-2019, 04:27 AM
Sorry Greg, I followed your code ... no go. What trigger do you expect...is it the change to the cb coz that is the private sub call. Thanks for your time.
cheers, Craig

gmaxey
04-01-2019, 05:55 AM
CraigP,

Yes, I meant is the trigger occurring? If you put a stop in the code and change the value in the combobox, does the code run? I you want, attach your document and I will look at it.

CraigP
04-02-2019, 04:48 AM
It does trigger when I change the cb but it gives an error at the first cb to be hidden...mmm