Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Macro to delete rows

    I have tried to write code to delete rows where txt " Detail L" appears to 2 rows below where "Detail L" , but the code
    "If Range("A" & i).Value = "Detail L" Then Range("A" & i).Resize(2).EntireRow.Delete
    Next i" comes up as invalid
    PHP Code:
    Sub Del_Unwanted()
    Dim LR As LongAs Long
    LR 
    Range("A" Rows.Count).End(xlUp).Row
    For LR To 1 Step -1
        
    If Range("A" i).Value "Detail L" Then Range("A" i).Resize(2).EntireRow.Delete
    Next i
    End SubS 
    Your assistance in this regard will be most appreciated

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    The code looks fine to me apart from the End SubS line (should be End Sub)
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    The code looks fine to me apart from the End SubS line (should be End Sub)
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi Rory

    Thanks for the reply. It appears that the S at the end of End Sub was causing the problem

Posting Permissions

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