[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:
Range("A5").Select
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
Dim issue As String
Dim Date1 As String
issue = Range("B3").Value
Date1 = Range("B2").Value
Do Until activeCell.Value = "F00STOP"
If activeCell.Value = "F00" Then
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
'Cells.FindNext(after:=activeCell).activate
Else
[COLOR=Red]Dim carry As String
carry = activeCell.Value[/COLOR]
Windows("Equipment Log.xls").activate
Range("B4").Select
Do Until activeCell.Value = 1
If activeCell = carry Then
activeCell([1], [2]).Select
activeCell = issue
activeCell([1], [2]).Select
activeCell = Date
Range("E1").Select
Else
activeCell.Offset([1], [0]).activate
End If
Loop
Windows("Material Reconciliation Slips.xls").activate
[COLOR=Red]Cells.Find(What:=carry, after:=activeCell, LookIn:=xlFormulas, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate[/COLOR]
End If
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlFormulas, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
Loop
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.