LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Arrays with one item

Hello all

I have a procedure which creates an array based upon values in a named
range. There's three possible ranges which can be selected. The first
two ranges contain more than one value, whereas my third only contains
one item.

I create the array as follows. (The gstrReportingArea variable relates
to one of the three possible ranges, and mwshtVariablesConstants is a
worksheet object variable).

Public gaFactoryAreas() As String
'Create variable array to hold factory areas
c = mwshtVariablesConstants.Range("var" & gstrReportingArea &
"_FactoryAreas").Columns.Count
ReDim gaFactoryAreas(1 To c)
For i = 1 To c
gaFactoryAreas(i) = mwshtVariablesConstants.Range("var" &
gstrReportingArea & "_FactoryAreas").Cells(1, i)
Next i

My problem relates to when I try to use gaFactoryAreas array in a 'For
Each' loop.

When I have only one item in gaFactoryAreas, the loop fails, whereas if
there's more than one item it fails.

Does anyone have any suggestions on how to deal with the possibility
that there may only be one item in an array. I'"m trying to avoid using
lots of IF statements.

Regards

 
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
Looking up whether one item has a certain matching item Thocow Excel Worksheet Functions 6 March 31st 10 04:39 PM
Macro to ask for a item# and then show all details for that item Durai Excel Discussion (Misc queries) 5 December 4th 09 08:17 PM
To find rate of each item from item.xls and to copy price.xls pol Excel Discussion (Misc queries) 7 July 16th 09 12:49 AM
Item numbers result in item description in next field in Excel Cheryl MM Excel Worksheet Functions 1 February 20th 07 03:51 PM
Selecting an Item from a List and getting a different item to pop. Matt Excel Worksheet Functions 1 December 7th 04 02:37 PM


All times are GMT +1. The time now is 05:29 PM.

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

About Us

"It's about Microsoft Excel"