View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Brian Brian is offline
external usenet poster
 
Posts: 683
Default Non-Sequential Count

Joel thanks for the help over the past few days. This worked fine when I
explicitly stated the numbers; however, when I do something like the
following I get Subscript Out of Range error:

Dim strABC as String, lResult as Long

strABC = "1,2,5,6,7,8"
num=array(strABC)
For each count in num
lResult = lResult + Worksheets(count).Range("A1").Value
Next count
MsgBox lResult

I'm using criteria to build the string strABC, so this is just an example,
and I can't explicitly say what numbers I want.

Thanks again.
--
Brian


"Joel" wrote:

num = array(1,2,5,7,8)
For each count in num

"Brian" wrote:

I know normally to do a count one would use

For count = 1 To 4
Next count

But what if I don't want to do 1-4, and I wanted to do like 1,2,5-8?
What would I use then?
--
Brian