Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Displaying all the states in a VBA combobox
Hey
Is there a special code that will display all the states in the USA in a combobox or do I have to do this manually? Thanx Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Displaying all the states in a VBA combobox
You have to do it by macro.
-- Jim Rech Excel MVP |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Displaying all the states in a VBA combobox
Here is some code I posted back in 2001
Sub AddState() aStates = Array _ ("Alabama", "Alaska", "Arizona", "Arkansas", "California", _ "Colorado", "Connecticut", "Delaware", "Florida", _ "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", _ "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", _ "Maryland", "Massachusetts", "Michigan", "Minnesota", _ "Mississippi", "Missouri", "Montana", "Nebraska", _ "Nevada", "New Hampshire", "New Jersey", "New Mexico", _ "New York", "North Carolina", "North Dakota", "Ohio", _ "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", _ "South Carolina", "South Dakota", "Tennessee", "Texas", _ "Utah", "Vermont", "Virginia", "Washington", _ "West Virginia", "Wisconsin", "Wyoming") For Each cell In Range("A1:A50") cell.Offset(0, 1).Value = aStates(cell.Value - 1) Next End Sub change it to Sub AddState() Dim aStates as Variant Dim i as Long aStates = Array _ ("Alabama", "Alaska", "Arizona", "Arkansas", "California", _ "Colorado", "Connecticut", "Delaware", "Florida", _ "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", _ "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", _ "Maryland", "Massachusetts", "Michigan", "Minnesota", _ "Mississippi", "Missouri", "Montana", "Nebraska", _ "Nevada", "New Hampshire", "New Jersey", "New Mexico", _ "New York", "North Carolina", "North Dakota", "Ohio", _ "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", _ "South Carolina", "South Dakota", "Tennessee", "Texas", _ "Utah", "Vermont", "Virginia", "Washington", _ "West Virginia", "Wisconsin", "Wyoming") For i = lbound(aStates) to ubound(aStates) Userform1.combobox1.AddItem aStates(i) Next 'or just ' Userform1.combobox1.List = aStates End Sub -- Regards, Tom Ogilvy Todd Huttenstine wrote in message ... Hey Is there a special code that will display all the states in the USA in a combobox or do I have to do this manually? Thanx Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Display Excel 2007 data by states using United States (US) map | Excel Discussion (Misc queries) | |||
Percentile for specific states | Excel Worksheet Functions | |||
How can I create a U.S. map where I can mark certain states? | Charts and Charting in Excel | |||
US states | Excel Worksheet Functions | |||
How to find top five States? | Excel Worksheet Functions |