nick lanta
nick lanta

Reputation: 638

How to split the 2nd dimension of a for loop?

If I have a for/next loop, but have a column splitting up the range I need to apply the array print to, how would I go about splitting that?

Example:

For i = 0 To 4 '5 rows
    For j = 3 To 5 'apply across 3 columns
        Set c = wsA.Cells(fndRow + i, j + 43)
        c.Interior.Color = VBA.RGB(255, 255, 0)
        wsA.Cells(fndRow + i, j + 43).Value = rIterator.Offset(, j - 1).Value * multplr(i)
    Next j
Next I

I want to split my array print between 3 columns skip over a column and then the next three columns like:

For j = 3 to 5, 7 to 9 

I know this isn't the correct syntax, but it conveys my point in the question. Any thoughts? Would I need to create another for loop?

Upvotes: 0

Views: 34

Answers (1)

Tim Williams
Tim Williams

Reputation: 166511

For j = 3 to 9
    if j<>6 Then
        'do stuff
    end if
next j

Upvotes: 1

Related Questions