Results 1 to 5 of 5

Thread: Exiting a Loop [Resolved]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    Australia
    Posts
    46

    Resolved Exiting a Loop [Resolved]

    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.

    VB Code:
    1. For i = 2 To 16
    2.  
    3.         x = i + 1
    4.         EmployeeName = Sheets("Summary").Cells(i, 1)
    5.         EmployeeNum = Sheets("Summary").Cells(i, 2)
    6.         EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
    7.         Sheets(EmployeeName).Select
    8.         Columns("A:J").Select
    9.         Selection.ClearContents
    10.         If EmployeeNum = 0 Then
    11.             Next i
    12.         End If
    13.         If EmployeeNumEnd = 0 Then
    14.             x = i + 2
    15.             EmployeeNumEnd = Sheets("Summary").Cells(x, 2)
    16.         End If
    17.         ActiveWorkbook.Sheets("Import").Select
    18.         y = EmployeeNumEnd - 1
    19.         Rows(EmployeeNum & ":" & y).Select
    20.         Selection.Cut
    21.         Sheets(EmployeeName).Select
    22.         Range("A3").Select
    23.         ActiveSheet.Paste
    24.         Range("A1") = DateReport
    25.         Range("A2:J2") = Heading
    26.         Range("A1").Select
    27.     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
    Last edited by Pearso; Jun 9th, 2005 at 06:15 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