Working with a Loop

  • Thread starter Thread starter R Tanner
  • Start date Start date
R

R Tanner

I can't figure out why this double loop does not work...

For X = 1 To 9
For T = 1 To 11
range("SP[DATE]").Select
Selection.Find(What:=CURRPERCENTAGE.Value, After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Offset(0,
1).Activate
CURRPERCENTAGE.Offset(X, 0) = ActiveCell
Set CURRPERCENTAGE = CURRPERCENTAGE.Offset(0, 1)
T = T + 1
MsgBox T
Next

Next

If you have any idea, it would be greatly appreciated..I have tried
everything...
 
It would have helped if you had told us what "does not work" meant (did you
see an error message, which one, nothing happened, etc.). I do note that you
have T=T+1 in your code... perhaps that statement is your problem as it
would force T to increment by two on each loop (once for that statement and
once more from the For statement itself. Comment that statement out and see
if that corrects your problem.
 
I didn't try his code... I just am pretty sure the T=T+1 is not right (if
the OP really needed this, he would simply have to use a Step 2 qualifier on
his For statement line).

--
Rick (MVP - Excel)


Elmtree said:
I copied the code and tried it myself.

I removed the T = T + 1 line. also removed the code inside the T loop.

It increments by 1 now, but when it finishes with T, it repeats the T
loop.


That may be his problem.




Rick said:
It would have helped if you had told us what "does not work" meant (did
you
see an error message, which one, nothing happened, etc.). I do note that
you
have T=T+1 in your code... perhaps that statement is your problem as it
would force T to increment by two on each loop (once for that statement
and
once more from the For statement itself. Comment that statement out and
see
if that corrects your problem.
I can't figure out why this double loop does not work...
[quoted text clipped - 17 lines]
If you have any idea, it would be greatly appreciated..I have tried
everything...
 
It may be best to start from the beginning and tell us your layout and what
you want to happen.
I can't see T doing anything and selections are not necessary.

If desired, send your workbook to my address below along with an explanation
and I'll take a look.
 

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

Back
Top