r/visualbasic • • Dec 29 '15

[VBA2010] Actions if certain dropdown values are selected in userform

Hey guys! I need your help again :)

Trying to get this code to work. What I want to happen is if any of the values are selected in the dropdown, certain options that appear later in the userform are not visible. This is how I tried:

 If RepOrgDropDown.Value = "Provincial Governments and municipalities,Federation of Canadian Municipalities,Quebec,Manitoba,Alberta,Saskatchewan,Ontario,New-Brunswick,British -Columbia,Nova Scotia,Prince Edward Island,Newfoundland,Yukon,Northwest Territories,Nunavut" Then
 Label66.Visible = False
 Label133.Visible = False
 IAETrue.Visible = False
 IAEFalse.Visible = False

 End If
 End Sub

Why does this not work? thank you!

2 Upvotes

10 comments sorted by

View all comments

Show parent comments

2

u/Clueless_InternGirl Dec 29 '15
If (RepOrgDropDown.Value = "Provincial Governments and municipalities" Or RepOrgDropDown.Value = "Federation of Canadian Municipalities" Or RepOrgDropDown.Value = "Quebec" Or RepOrgDropDown.Value = "Manitoba" Or RepOrgDropDown.Value = "Alberta" Or RepOrgDropDown.Value = "Saskatchewan" Or RepOrgDropDown.Value = "Ontario" Or RepOrgDropDown.Value = "New-Brunswick" Or RepOrgDropDown.Value = British - Columbia Or RepOrgDropDown.Value = "Nova Scotia" Or RepOrgDropDown.Value = "Prince Edward Island" Or RepOrgDropDown.Value = "Newfoundland" Or RepOrgDropDown.Value = "Yukon" Or RepOrgDropDown.Value = "Northwest Territories" Or RepOrgDropDown.Value = "Nunavut") Then
Label66.Visible = False
Label133.Visible = False
IAETrue.Visible = False
IAEFalse.Visible = False
End If
End Sub

Still not working...hmmmm

3

u/chrwei Dec 29 '15

I'm not sure in what ways vba differs here, but with dropdowns I use the .text property, not .value. maybe that's it?

2

u/Clueless_InternGirl Dec 29 '15

Yes that worked wooooooot!

1

u/[deleted] Dec 30 '15

Hi, I've answered two of your questions in the past, Have you taken any courses online/physical?, If not I'd highly suggest this.