Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do you loop NON-SEQUENTIALLY?


I need to loop through my code using a counter index which i
non-systematic. For example, j = 1,3, 11,12,30,40,99 .... I intuitivel
attempted the following (based on j in this example) but which failed.

For i = 1 To 7
For j = Array( 1,3, 11,12,30,40,99)
Cells(j, "a") = "testing"
Next
Next

The idea is to get the loop working the first time and then apply a
outer loop to run through several sheets with identical spreadshee
format.

Thanks for any help.

Davi

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=37891

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How do you loop NON-SEQUENTIALLY?


also:

dim vRow as variant
for each vRow in Array(1,3,11)
activesheet.Cells(vRow,1) = "test"
next




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


davidm wrote :


I need to loop through my code using a counter index which is
non-systematic. For example, j = 1,3, 11,12,30,40,99 .... I
intuitively attempted the following (based on j in this example) but
which failed.

For i = 1 To 7
For j = Array( 1,3, 11,12,30,40,99)
Cells(j, "a") = "testing"
Next
Next

The idea is to get the loop working the first time and then apply an
outer loop to run through several sheets with identical spreadsheet
format.

Thanks for any help.

David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How do you loop NON-SEQUENTIALLY?

I don't think you want that -1 there--unless you wanted to ignore the 99.

For j = lbound(myarr) to ubound(myarr)

makes it so you don't have to worry about what the base (0 or 1) is for your
array.

mangesh_yadav wrote:

Try this:

Private Sub CommandButton1_Click()

myArr = Array(1, 3, 11, 12, 30, 40, 99)

For i = 1 To 7
For j = 0 To UBound(myArr) - 1
Cells(myArr(j), "a") = "testing"
Next
Next
End Sub

Mangesh

--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=378912


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do you loop NON-SEQUENTIALLY?


Hi Dave,

thanks for the suggestion. The lower bound is always what on
overlooks, and simply assumes it to be 0 or 1 :)

Manges

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=37891

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do you loop NON-SEQUENTIALLY?


Thanks Mangesh and all. I also stumbled across this solution which I
wiosh to share.

For i = 1 to [1:1,3:3, 11:11,12:12,30:30,40:40,99:99,100:125].Rows
Cells(j.Rows,1)="test"
Next

The last item 100:125 in the array covers the range 100-125, and for
this exercise picks up Cells A100 to Cells A125 serially.

David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=378912

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
fill down sequentially JMC Excel Worksheet Functions 1 June 3rd 09 06:55 PM
sorting sequentially Lise Excel Discussion (Misc queries) 4 October 21st 08 03:58 AM
NAME SHEETS sequentially Steve Excel Discussion (Misc queries) 4 October 5th 06 05:37 PM
How do you loop NON-SEQUENTIALLY? mangesh_yadav[_311_] Excel Programming 0 June 14th 05 10:02 AM
Run Macros Sequentially William[_2_] Excel Programming 1 June 8th 04 03:21 PM


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