Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Handling an array

Another one:

Dim res As Variant 'could be an error
Dim myArr As Variant
Dim myStart As Long
Dim iCtr As Long

myArr = Array(2, 4, 6, 8, 10)
myStart = 6

res = Application.Match(myStart, myArr, 0)

If IsError(res) Then
'not a valid starting position!
'what should happen?
MsgBox "No match"
Else
For iCtr = LBound(myArr) + res - 1 To UBound(myArr)
MsgBox myArr(iCtr)
Next iCtr
End If


Otto Moehrbach wrote:

Excel XP & Win XP
I need some help with an array problem.
I have an array of column numbers, say, 2,4,6,8,10. This array is fixed. I
want to run a FOR loop through this array. The variable is the point at
which I want to start. IOW, my target (or starting) column may be, say, 6.
I then want to run the FOR loop through columns 6,8,10 only.
My question is then: Given the starting column, how would I code a FOR loop
through this array? Thanks for your time. Otto


--

Dave Peterson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Handling an array

Thanks Dave. That's what I was looking for. I knew I had seen the indexing
of a value within an array before but I couldn't find it. Otto
"Dave Peterson" wrote in message
...
Another one:

Dim res As Variant 'could be an error
Dim myArr As Variant
Dim myStart As Long
Dim iCtr As Long

myArr = Array(2, 4, 6, 8, 10)
myStart = 6

res = Application.Match(myStart, myArr, 0)

If IsError(res) Then
'not a valid starting position!
'what should happen?
MsgBox "No match"
Else
For iCtr = LBound(myArr) + res - 1 To UBound(myArr)
MsgBox myArr(iCtr)
Next iCtr
End If


Otto Moehrbach wrote:

Excel XP & Win XP
I need some help with an array problem.
I have an array of column numbers, say, 2,4,6,8,10. This array is fixed.
I
want to run a FOR loop through this array. The variable is the point at
which I want to start. IOW, my target (or starting) column may be, say,
6.
I then want to run the FOR loop through columns 6,8,10 only.
My question is then: Given the starting column, how would I code a FOR
loop
through this array? Thanks for your time. Otto


--

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
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
Array handling error RichardSchollar Excel Programming 2 January 25th 07 04:11 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Handling ubound on an uninitialised array Mike NG Excel Programming 14 January 24th 05 09:05 AM


All times are GMT +1. The time now is 11:40 AM.

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"