For next

M

Mike

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.
 
J

JLGWhiz

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
 
R

Rick Rothstein

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top