For Each...Next statement

H

Hardy

Hi,

Not that familiar with loops etc.

I think what I need is for..next statement loop, as this is for each
element in group.

My group would be list of varialbes (integers) that are non-sequential,
that are gained via match function in VBA (they are column numbers of
data).

So, looping through 1,4,7,9,15 etc., rather than 1,2,3,4 etc.

I have searched and searched but cannot get my head round how to create
group or array to achieve this.

The code that I want to use in my loop is below (not that relevant to
question);

Set riBoxxFilteredCol = Intersect(ActiveSheet.Columns(iIBOXXColNo),
rng) ' Loops through series of integer variables
riBoxxFilteredCol.Copy
Worksheet(NowSheetName).Activate
Range("B1").Activate
ActiveCell.Offset(0, iNowColNo).Activate ' This is varialbe in loop (1
to 9)

It's iBOXXColNo that will loop through non-sequential list mentioned
above.

Thanks in advance.
 
T

Tom Ogilvy

varr = Array( 1,4,7,9,15)

for i = lbound(varr) to ubound(varr)
iIBOXXColNo = varr(i)
. . .

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