Private Sub UserForm_Initialize() Dim x As Integer For x = 2010 To 2015 cboYear.AddItem x Next cboStations.AddItem "Annual" cboStations.AddItem "Urban" End Sub Private Sub cboStations_Change() If cboYear.Value <> "" Then UpdateDistrict End If End Sub Private Sub cboYear_Change() If cboStations.Value <> "" Then UpdateDistrict End If End Sub Private Sub UpdateDistrict() Dim myArray() Dim myElement As Variant cboDistrict.Clear myArray = Array() If cboStations.Text = "Annual" Then If cboYear.Text = "2010" Or cboYear.Text = "2011" Or cboYear.Text = "2012" Then myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ' ElseIf cboYear.Text = "2011" Then ' myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ' ElseIf cboYear.Text = "2012" Then ' myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ' ElseIf cboYear.Text = "2012" Then ' myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ' ElseIf cboYear.Text = "2013" Then ' myArray = Array() ' ElseIf cboYear.Text = "2014" Then ' myArray = Array() End If ElseIf cboStations.Text = "Urban" Then If cboYear.Text = "2010" Then myArray = Array("Abilene", "Amarillo", "Austin", "San_Antonio", "Waco", "Wichita_Falls") ElseIf cboYear.Text = "2011" Then myArray = Array("Beaumont", "Houston") ElseIf cboYear.Text = "2012" Then 'or just Else myArray = Array("Brownwood", "Bryan", "Childress", "Corpus_Christi", "El_Paso", "Lubbock", "Odessa", "Yoakum") ' ElseIf cboYear.Text = "2013" Then ' myArray = Array() ' ElseIf cboYear.Text = "2014" Then ' myArray = Array() End If End If For Each myElement In myArray cboDistrict.AddItem myElement Next End Sub
I understand I always make the right comment. I will definitely be more attentive to my comments. Thanks to you both for continuing to teach me the rules and ways of the forum and of VBA. I will most certainly use the post icons.
I ended up getting the first helpful post in this thread and I didn't even do anything - my guilt will set in later today I'm sure.
Any logged in user can use the �??arrow�?� icons on the far right to vote for any of the replies on any threads if they believe that reply contains useful information. Users may vote for more than one reply in a thread. This voting tool allows the ArcGIS user community as a whole to collectively bubble the best replies to the top of the thread. This does two things: It allows other users later to find the most useful information most quickly without necessarily reading all of the posts in the thread.It rewards the reply�??s author with points that contribute to their status within the community, allowing other users to identify the most helpful members of the community, building trust and encouraging collaboration.
Thank You so much, you are the only one that has gotten this to work.
Can't do the years like that because Urban only has the years of 2010, 2011, and 2012.
Dim myArray() As String Dim myElement As Variant cboDistrict.Clear If cboStations.Text = "Annual" Then If cboYear.Text = "2010" Then myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ElseIf cboYear.Text = "2011" Then myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ElseIf cboYear.Text = "2012" Then myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ElseIf cboYear.Text = "2012" Then myArray = Array("Abilene", "Amarillo", "Atlanta", "Austin", "Beaumont", "Brownwood", "Bryan", "Childress", "Corpus_Christi", "Dallas", "El_Paso", "Fort_Worth", "Houston", "Laredo", "Lubbock", "Lufkin", "Odessa", "Paris", "Pharr", "San Angelo", "San_Antonio", "Tyler", "Waco", "Wichita_Falls", "Yoakum") ElseIf cboYear.Text = "2013" Then myArray = Array() ElseIf cboYear.Text = "2014" Then myArray = Array() End If ElseIf cboStations.Text = "Urban" Then If cboYear.Text = "2010" Then myArray = Array("Abilene", "Amarillo", "Austin", "San_Antonio", "Waco", "Wichita_Falls") ElseIf cboYear.Text = "2011" Then myArray = Array("Beaumont", "Houston") ElseIf cboYear.Text = "2012" Then 'or just Else myArray = Array("Brownwood", "Bryan", "Childress", "Corpus_Christi", "El_Paso", "Lubbock", "Odessa", "Yoakum") End If End If For Each myElement In myArray cboDistrict.AddItem myElement Next
dim myArray() as String dim myElement as Variant cboDistrict.Clear If cboStations.Text = "Urban" Then etc. End If For Each myElement in myArray cboDistrict.AddItem myElement Next
ElseIf cboStations.Text = "Urban" Then If cboYear.Text = "2010" Then myArray = Array("Abilene", "Amarillo", "Austin", "San_Antonio", "Waco", "Wichita_Falls") ElseIf cboYear.Text = "2011" Then myArray = Array("Beaumont", "Houston") ElseIf cboYear.Text = "2012" Then 'or just Else myArray = Array("Brownwood", "Bryan", "Childress", "Corpus_Christi", "El_Paso", "Lubbock", "Odessa", "Yoakum") End If End If For Each myElement In myArray cboDistrict.AddItem myElement Next End Sub
If cboStations.Text = "Annual" Then myArray = Array("Abilene", ... Else If cboStations.Text = "Urban" Then ' or just Else If if you won't have additional stations If cboYear.Text = "2010" Then myArray = Array("Abilene", ... etc End If For Each myElement in myArray cboDistrict.AddItem myElement Next
cboYear.Clear If cboStations.Text = "Urban" Then cboYear.AddItem "2010" cboYear.AddItem "2011" cboYear.AddItem "2012" Elseif cboStations.Text = "Rural" Then cboYear.AddItem "2011" End If
Private Sub cboYear_Change() dim myArray() as String cboDistrict.Clear If cboStations.Text = "Urban" Then If cboYear.Text = "2010" Then myArray = Array ("Abilene", "Amarillo", "Austin", "San_Antonio", "Waco", "Wichita_Falls" ) Elseif cboYear.Text = "2011" Then myArray = Array ("Beaumont", "Houston") Elseif cboYear.Text = "2012" Then 'or just Else myArray = Array ("Brownwood", "Bryan", "Childress", "Corpus_Christi", "El_Paso", Lubbock, "Odessa", "Yoakum") End If Elseif cboStations.Text = "Rural" If cboYear.Text = "2010" Then myArray = Array ("Abilene", "Waco", "Wichita_Falls" ) Elseif cboYear.Text = "2011" Then myArray = Array ("Beaumont") Elseif cboYear.Text = "2012" Then 'or just Else myArray = Array ("Brownwood", Lubbock, "Odessa", "Yoakum") End If End If For Each myElement in myArray cboDistrict.AddItem myElement Next End Sub
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.