Results 1 to 4 of 4

Thread: If and End with
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2014
    Posts
    301
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default If and End with

    Hi everyone

    There is an error 'End if without block if' with the code below:

    Please could anyone help.

    Code:
    Sub RemoveRows()
        Sheet1.Select
        Dim x As Long,LastRow As Long
    
        LastRow = Cells(Rows.Count,"A").End(xlUp).Row
    
        For x = LastRow To2 Step -1
            If Cells(x,3).Value <> "FASS" And Cells(x, 3).Value <>"FBL" And Cells(x, 3).Value <> "LTI-A" And Cells(x,3).Value <> "STEM" _
                AndCells(x, 3).Value <> "STEM" And Cells(x, 3).Value <>"MOOC FASS" And Cells(x, 3).Value <> "ApprentFBL" AndCells(x, 3).Value <> "ApprentSTEM" _
                AndCells(x, 3).Value <> "PG FutureLearn" And Cells(x, 3).Value<> "MA Non-project" And Cells(x, 3).Value <>"Student Hub Live" _
                AndCells(x, 3).Value <> "Editorial" And Cells(x, 3).Value <>"Editorial (Maintenance)" And Cells(x, 3).Value <>"Graphics" _
                AndCells(x, 3).Value <> "IMD" And Cells(x, 3).Value <>"Learning Design" Then _
               Rows(x).Delete
            End If
        Next x
    
    End Sub

  2. #2
    Board Regular Akuini's Avatar
    Join Date
    Feb 2016
    Location
    Indonesia
    Posts
    2,148
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    4 Thread(s)

    Default Re: If and End with

    Remove the last underscore (_)
    And Cells(x, 3).Value <> "IMD" And Cells(x, 3).Value <>"Learning Design" Then
    _

  3. #3
    Board Regular
    Join Date
    Nov 2014
    Posts
    301
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: If and End with

    Excellent! It works! Many thanks!

  4. #4
    Board Regular Akuini's Avatar
    Join Date
    Feb 2016
    Location
    Indonesia
    Posts
    2,148
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    4 Thread(s)

    Default Re: If and End with

    You're welcome

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •