#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default arrays

Hi,

I want to work with an array which contains state names (e.g. Dim
strStateNames(49) as String). Is there an easy way to fill the array
without getting the data somewhere else? For instance:

strStateNames(1 To 50) = "Alabama", "Alaska", "Arizona", "Arkansas", etc.

instead of:

strStateNames(0) = "Alabama"
strStateNames(1) = "Alaska"
strStateNames(2) = "Arizona"
etc. (ugh!)

I know I can put the names in a worksheet and then:

For i = 0 To 49
strStateNames(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Next i

But is there an easy way to do this without going somewhere else for the
data? Thanks.

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default arrays

Dim strSplit() as String
Dim strStates as String: states = "Alabama,Alaska,Arizona,Arkansas,etc"

strSplit = Split(strStates, Chr(44), -1, vbBinaryCompare)


Tim Riley




"Dave B" wrote in message
...
Hi,

I want to work with an array which contains state names (e.g. Dim
strStateNames(49) as String). Is there an easy way to fill the array
without getting the data somewhere else? For instance:

strStateNames(1 To 50) = "Alabama", "Alaska", "Arizona", "Arkansas", etc.

instead of:

strStateNames(0) = "Alabama"
strStateNames(1) = "Alaska"
strStateNames(2) = "Arizona"
etc. (ugh!)

I know I can put the names in a worksheet and then:

For i = 0 To 49
strStateNames(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Next i

But is there an easy way to do this without going somewhere else for the
data? Thanks.

Dave




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default arrays

Another way:

dim strStateNames as Variant
strStateNames = array("alabama", "alaska", "West Virginia")

or even:

Dim strStateNames As Variant
strStateNames _
= Application.Transpose(Worksheets("sheet1").Range(" a1:a50").Value)

But the bottom one is a base 1 array (1 to 50)


Dave B wrote:

Hi,

I want to work with an array which contains state names (e.g. Dim
strStateNames(49) as String). Is there an easy way to fill the array
without getting the data somewhere else? For instance:

strStateNames(1 To 50) = "Alabama", "Alaska", "Arizona", "Arkansas", etc.

instead of:

strStateNames(0) = "Alabama"
strStateNames(1) = "Alaska"
strStateNames(2) = "Arizona"
etc. (ugh!)

I know I can put the names in a worksheet and then:

For i = 0 To 49
strStateNames(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Next i

But is there an easy way to do this without going somewhere else for the
data? Thanks.

Dave


--

Dave Peterson

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
Arrays David Excel Discussion (Misc queries) 2 May 12th 09 10:16 PM
Two arrays same? FARAZ QURESHI Excel Discussion (Misc queries) 4 April 23rd 09 12:22 AM
Arrays Abdul Shakeel Excel Worksheet Functions 1 December 12th 08 10:24 AM
Use of arrays DKS Excel Worksheet Functions 1 November 30th 06 08:38 PM
3D Arrays DB Excel Worksheet Functions 2 October 10th 05 03:50 PM


All times are GMT +1. The time now is 09:09 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"