Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Working with a Loop

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...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Working with a Loop

I see where you increment T .... T = T + 1

But not for X ???

R Tanner wrote:
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...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default Working with a Loop

Elmtree wrote:
I see where you increment T .... T = T + 1

But not for X ???

R Tanner wrote:
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...



Both T and X are incremented in the for/next loops.

The thing that caught my eye is T is also incremented by T = T + 1
/inside/ the T loop. This amounts to evaluating T as 1, 3, 5, etc.,
although the MsgBox will report 2, 4, 6, etc. I don't know what the OP
is trying to do here, but this seems odd to me.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Working with a Loop

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.

--
Rick (MVP - Excel)


"R Tanner" wrote in message
...
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...


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Working with a Loop

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 Rothstein wrote:
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...




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Working with a Loop

Let me clairfy my last statement.

I think it works OK once you take the T = T + 1 line out.

What he sees is the T msgbox repeating itself. But what he does not see is
the X value.

I put in a X msgbox, it loops the T until X = 9, then ends.



Maybe this fixed his problem....


Elmtree wrote:
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.

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

[quoted text clipped - 8 lines]
If you have any idea, it would be greatly appreciated..I have tried
everything...


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Working with a Loop

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" <u45848@uwe wrote in message news:8969c64ac70b5@uwe...
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 Rothstein wrote:
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...



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Working with a Loop

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.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"R Tanner" wrote in message
...
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...


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
For...Each loop not working Jayne22 Excel Programming 5 August 13th 08 03:22 PM
Do Until Loop Not Working PJFry Excel Programming 3 October 1st 07 07:20 PM
Loop Not Working Paul Black Excel Programming 7 August 29th 07 08:33 PM
Why is this loop not working? Mike R. Excel Programming 12 July 25th 07 02:26 PM
Do...Loop not working Sunny Lin Excel Programming 1 April 14th 05 01:19 AM


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"