Pearso
Jun 8th, 2005, 06:50 PM
Hello all,
I have a loop which i want to skip to the next i if a condition is meet how do i do this. My code is.
For i = 2 To 16
x = i + 1
EmployeeName = Sheets("Summary").Cells(i, 1)
EmployeeNum = Sheets("Summary").Cells(i, 2)
EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
Sheets(EmployeeName).Select
Columns("A:J").Select
Selection.ClearContents
If EmployeeNum = 0 Then
Next i
End If
If EmployeeNumEnd = 0 Then
x = i + 2
EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
End If
ActiveWorkbook.Sheets("Import").Select
y = EmployeeNumEnd - 1
Rows(EmployeeNum & ":" & y).Select
Selection.Cut
Sheets(EmployeeName).Select
Range("A3").Select
ActiveSheet.Paste
Range("A1") = DateReport
Range("A2:J2") = Heading
Range("A1").Select
Next i
The problem i'm having is in the first IF statment is says that the Next i is not matched with and for statment. How can do what i'm trying to achieve.
Any help would be greatly appreicated.
Regards,
Pearso :confused:
I have a loop which i want to skip to the next i if a condition is meet how do i do this. My code is.
For i = 2 To 16
x = i + 1
EmployeeName = Sheets("Summary").Cells(i, 1)
EmployeeNum = Sheets("Summary").Cells(i, 2)
EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
Sheets(EmployeeName).Select
Columns("A:J").Select
Selection.ClearContents
If EmployeeNum = 0 Then
Next i
End If
If EmployeeNumEnd = 0 Then
x = i + 2
EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
End If
ActiveWorkbook.Sheets("Import").Select
y = EmployeeNumEnd - 1
Rows(EmployeeNum & ":" & y).Select
Selection.Cut
Sheets(EmployeeName).Select
Range("A3").Select
ActiveSheet.Paste
Range("A1") = DateReport
Range("A2:J2") = Heading
Range("A1").Select
Next i
The problem i'm having is in the first IF statment is says that the Next i is not matched with and for statment. How can do what i'm trying to achieve.
Any help would be greatly appreicated.
Regards,
Pearso :confused: