P
Paul987
The following code cycles cell "r" through several If/Else statements.
The section between the "****" is where I'm having a problem. It work
fine as long as r doesn't meet any requirements. It goes to the nex
like it should. However, when r does qualify one of the statement
between the ****'s, it does that action but doesn't go to next. I
starts over and resets r. Therefore, the code gets stuck in a loop
Interestingly though, it eventually gets out successfully after about
minute, but I'm not sure how.
Any ideas?. I'm sure Im missing something simple.
This runs constantly in the background on a large sheet, and I'm new t
VBA, so If you know of any ways to make this run faster, I'm all ears.
I've spent one day trying to figure this out, figures it was time to as
for help. TIA
Paul
Dim lastrow As Long, r As Long
lastrow = Workbooks("TAStrategyUS.xls").Sheets("Ope
Positions").Cells(Rows.Count, "A").End(xlUp).Row
If Workbooks("TAStrategyUS.xls").Sheets("Open Positions").Cells(1, 17
= "ON" Then
For r = 5 To lastrow
If Workbooks("xxx").Sheets("xxx").Cells(r, 9) < -0.07 An
Workbooks("xxx").Sheets("xxx").Cells(r, 5) = "" Then
On Error Resume Next
MsgBox "xxx" & Workbooks("xxx").Sheets("xxx").Cells(r, 3)
" " & Workbooks("xxx").Sheets("xxx").Cells(r, 1) & " at "
Workbooks("xxx").Sheets("xxx").Cells(r, 6) & "xxx"
Workbooks("xxx").Sheets("xxx").Cells(r, 5) = "xxx"
End If
If Workbooks("xxx").Sheets("xxx").Cells(r, 16)
Workbooks("xxx").Sheets("xxx").Cells(r, 9) Then
Workbooks("xxx").Sheets("xxx").Cells(r, 16)
Workbooks("xxx").Sheets("xxx").Cells(r, 9)
End If
*******************************************
If Workbooks("xxx").Sheets("xxx").Cells(r, 9) >= 0.2 Then
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) = "" Then
Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(1, 14)
Else
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) <> "
And Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(r, 7) > 21 An
Workbooks("xxx").Sheets("xxx").Cells(r, 19) = "Yes" Then
Workbooks("xxx").Sheets("xxx").Cells(r, 18) = "Sel
" & Workbooks("xxx").Sheets("xxx").Cells(r, 3) & " @ "
Workbooks("xxx").Sheets("xxx").Cells(r, 20) + 0.01
Else
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) <
"" And Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(r, 7) < 22 Then
Workbooks("xxx").Sheets("xxx").Cells(r, 18)
"xxx" & Workbooks("xxx").Sheets("xxx").Cells(r, 7) + 56
End If
End If
End If
End If
Next r
*****************************************************
End If
End Su
The section between the "****" is where I'm having a problem. It work
fine as long as r doesn't meet any requirements. It goes to the nex
like it should. However, when r does qualify one of the statement
between the ****'s, it does that action but doesn't go to next. I
starts over and resets r. Therefore, the code gets stuck in a loop
Interestingly though, it eventually gets out successfully after about
minute, but I'm not sure how.
Any ideas?. I'm sure Im missing something simple.
This runs constantly in the background on a large sheet, and I'm new t
VBA, so If you know of any ways to make this run faster, I'm all ears.
I've spent one day trying to figure this out, figures it was time to as
for help. TIA
Paul
Dim lastrow As Long, r As Long
lastrow = Workbooks("TAStrategyUS.xls").Sheets("Ope
Positions").Cells(Rows.Count, "A").End(xlUp).Row
If Workbooks("TAStrategyUS.xls").Sheets("Open Positions").Cells(1, 17
= "ON" Then
For r = 5 To lastrow
If Workbooks("xxx").Sheets("xxx").Cells(r, 9) < -0.07 An
Workbooks("xxx").Sheets("xxx").Cells(r, 5) = "" Then
On Error Resume Next
MsgBox "xxx" & Workbooks("xxx").Sheets("xxx").Cells(r, 3)
" " & Workbooks("xxx").Sheets("xxx").Cells(r, 1) & " at "
Workbooks("xxx").Sheets("xxx").Cells(r, 6) & "xxx"
Workbooks("xxx").Sheets("xxx").Cells(r, 5) = "xxx"
End If
If Workbooks("xxx").Sheets("xxx").Cells(r, 16)
Workbooks("xxx").Sheets("xxx").Cells(r, 9) Then
Workbooks("xxx").Sheets("xxx").Cells(r, 16)
Workbooks("xxx").Sheets("xxx").Cells(r, 9)
End If
*******************************************
If Workbooks("xxx").Sheets("xxx").Cells(r, 9) >= 0.2 Then
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) = "" Then
Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(1, 14)
Else
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) <> "
And Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(r, 7) > 21 An
Workbooks("xxx").Sheets("xxx").Cells(r, 19) = "Yes" Then
Workbooks("xxx").Sheets("xxx").Cells(r, 18) = "Sel
" & Workbooks("xxx").Sheets("xxx").Cells(r, 3) & " @ "
Workbooks("xxx").Sheets("xxx").Cells(r, 20) + 0.01
Else
If Workbooks("xxx").Sheets("xxx").Cells(r, 17) <
"" And Workbooks("xxx").Sheets("xxx").Cells(r, 17)
Workbooks("xxx").Sheets("xxx").Cells(r, 7) < 22 Then
Workbooks("xxx").Sheets("xxx").Cells(r, 18)
"xxx" & Workbooks("xxx").Sheets("xxx").Cells(r, 7) + 56
End If
End If
End If
End If
Next r
*****************************************************
End If
End Su