Hi, I get the following error message with the below code, but it's not true, there IS a "For" statement. Where am I going wrong?? Sorry, forum has lost all my indent formatting. Thanks so much!
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Next without For
---------------------------
OK Help
---------------------------
----------------------------------------------------------------
Option Explicit
Private Sub CommandButton1_Click()
Dim fl As Boolean, r As Long, i, j, t, n, k, m, p, c As Integer, tr, br As String
fl = False
c = 0
m = Cells(3, 4).Value
Do Until fl = True
For i = 13 To 1000 'count trades
If Cells(i, 1) = "" Then fl = True
If Cells(i, 1) <> "" Then c = c + 1
Next i
Loop
fl = False ' reset fl for next count
i = 0
If OptionButton1.Value = True Then
'begin code for special assignment
MsgBox "There are " & Str(c) & " trades on tracking."
' excluded trades
Do Until fl = True
For i = 13 To c + 13
If Cells(i, 2).Value = "" Then fl = True
If Cells(i, 9) = False Then Cells(i, 6).Value = "EXCLUDED"
Next i
Loop
fl = False
'assignment
For i = 13 To 13 + c
If Cells(i, 13) <> "ignore" Then
p = Cells(i, 13)
If Cells(i, 10) = Worksheets(3).Cells(p, 1) Then
For n = 0 To 9
For k = 3 To 10
If Cells(i, 10) = Worksheets(3).Cells(p + n, 1) And Cells(k, 6) = Worksheets(3).Cells(p + n, 3) Then
If Cells(i, 6) <> "EXCLUDED" Then Cells(i, 6) = Cells(k, 6)
End If
Next k
Next n
End If
Next i
' end code for special assignment
ElseIf OptionButton2.Value = True Then
End If
End Sub
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Next without For
---------------------------
OK Help
---------------------------
----------------------------------------------------------------
Option Explicit
Private Sub CommandButton1_Click()
Dim fl As Boolean, r As Long, i, j, t, n, k, m, p, c As Integer, tr, br As String
fl = False
c = 0
m = Cells(3, 4).Value
Do Until fl = True
For i = 13 To 1000 'count trades
If Cells(i, 1) = "" Then fl = True
If Cells(i, 1) <> "" Then c = c + 1
Next i
Loop
fl = False ' reset fl for next count
i = 0
If OptionButton1.Value = True Then
'begin code for special assignment
MsgBox "There are " & Str(c) & " trades on tracking."
' excluded trades
Do Until fl = True
For i = 13 To c + 13
If Cells(i, 2).Value = "" Then fl = True
If Cells(i, 9) = False Then Cells(i, 6).Value = "EXCLUDED"
Next i
Loop
fl = False
'assignment
For i = 13 To 13 + c
If Cells(i, 13) <> "ignore" Then
p = Cells(i, 13)
If Cells(i, 10) = Worksheets(3).Cells(p, 1) Then
For n = 0 To 9
For k = 3 To 10
If Cells(i, 10) = Worksheets(3).Cells(p + n, 1) And Cells(k, 6) = Worksheets(3).Cells(p + n, 3) Then
If Cells(i, 6) <> "EXCLUDED" Then Cells(i, 6) = Cells(k, 6)
End If
Next k
Next n
End If
Next i
' end code for special assignment
ElseIf OptionButton2.Value = True Then
End If
End Sub