#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default For next

Is there a way to write a for next statement for some set numbers.

For instance, I want to have a loop to run for x = 4, 10, 19, 27.

Thanks,
Mike.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default For next

You can put the numbers in a range of cells, or in an array.
An array would go somethin like this.

Dim x As Variant
x = Array(4, 10, 19, 27)
For i = LBound(x) To UBound(x)
If x(i) = "something" Then
'Do something
End If
Next

"Mike" wrote:

Is there a way to write a for next statement for some set numbers.

For instance, I want to have a loop to run for x =4, 10, 19, 27 .

Thanks,
Mike.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default For next

Just read the values directly from the Array function...

Dim V As Variant
For Each V In Array(4, 10, 19, 27)
MsgBox V
Next

--
Rick (MVP - Excel)


"Mike" wrote in message
...
Is there a way to write a for next statement for some set numbers.

For instance, I want to have a loop to run for x = 4, 10, 19, 27.

Thanks,
Mike.


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



All times are GMT +1. The time now is 09:26 AM.

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"