Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Displaying all the states in a VBA combobox

You have to do it by macro.

--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Excel 2007 data by states using United States (US) map Beach Lover Excel Discussion (Misc queries) 0 March 24th 08 03:04 PM
Percentile for specific states Sam B[_2_] Excel Worksheet Functions 5 February 25th 08 10:59 PM
How can I create a U.S. map where I can mark certain states? JJP Charts and Charting in Excel 2 August 21st 07 05:44 PM
US states Tammy Excel Worksheet Functions 1 May 18th 06 04:44 PM
How to find top five States? Saadi Excel Worksheet Functions 7 February 15th 05 09:05 PM


All times are GMT +1. The time now is 01:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"