Results 1 to 1 of 1

Thread: [Resolved]Need help with this infinite loop

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    14

    Resolved [Resolved]Need help with this infinite loop

    Edit: Finally figured it out.

    I keep getting an infinite loop, and I know where the problem is occuring, but not how to fix it. Here is my code:

    VB Code:
    1. Range("A5").Select
    2.    
    3.    
    4.     Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    5.         xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    6.         False, SearchFormat:=False).activate
    7.        
    8.     Dim issue As String
    9.     Dim Date1 As String
    10.     issue = Range("B3").Value
    11.     Date1 = Range("B2").Value
    12.  
    13.     Do Until activeCell.Value = "F00STOP"
    14.    
    15.         If activeCell.Value = "F00" Then
    16.             Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    17.             xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    18.             False, SearchFormat:=False).activate
    19.        
    20.             'Cells.FindNext(after:=activeCell).activate
    21.         Else
    22.             [COLOR=Red]Dim carry As String
    23.             carry = activeCell.Value[/COLOR]
    24.        
    25.             Windows("Equipment Log.xls").activate
    26.        
    27.             Range("B4").Select
    28.        
    29.             Do Until activeCell.Value = 1
    30.        
    31.                 If activeCell = carry Then
    32.                     activeCell([1], [2]).Select
    33.                     activeCell = issue
    34.                     activeCell([1], [2]).Select
    35.                     activeCell = Date
    36.                     Range("E1").Select
    37.                 Else
    38.                     activeCell.Offset([1], [0]).activate
    39.                 End If
    40.        
    41.             Loop
    42.            
    43.             Windows("Material Reconciliation Slips.xls").activate
    44.            
    45.             [COLOR=Red]Cells.Find(What:=carry, after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    46.             xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    47.             False, SearchFormat:=False).activate[/COLOR]
    48.        
    49.         End If
    50.        
    51.         Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
    52.         xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    53.         False, SearchFormat:=False).activate
    54.    
    55.     Loop
    56.  
    57. End Sub


    I beleive the stuff in red is my problem. Something with that variable. Probably isn't working in the find function. Not positive though, nor do I know how to fix it. What I'm wanting it to do there is to go back to the location stored in the carry variable on the material worksheet. That way I can go through and update everything and then stop the program when it gets to F00STOP.

    Anyway, if anyone knows a solution or suggestions please let me know.
    Last edited by Sasaraii; Jun 30th, 2005 at 06:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width