Results 1 to 2 of 2

Code Is Deleting Header

Threaded View

zero635 Code Is Deleting Header 11-12-2008, 10:20 PM
zero635 Well, I think I answered my... 11-12-2008, 10:31 PM
  1. #1
    Registered User
    Join Date
    06-30-2005
    Posts
    23

    Smile Code Is Deleting Header

    I have the following code that will delete every row that doesn't meet the specified criteria. However, when I run it, it deletes the header which is in row A1 thru Y1. Can you tell me what I need to put in this code to stop it before it gets to the header?

    Sub DeleteRows()
    Application.ScreenUpdating = False
    
    Dim ws1 As Worksheet
    Dim Firstrow As Long
    Dim Lastrow As Long
    Dim Lrow As Long
    
    Set ws1 = ActiveSheet
    
    With ws1
    
        Firstrow = .UsedRange.Cells(2).Row
        Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
    
        For Lrow = Lastrow To Firstrow Step -1
           With .Cells(Lrow, "x")
                   If .Value <> "4SK5" And .Value <> "4S52" Then .EntireRow.Delete
           End With
    
        Next Lrow
    
    End With
    
    Application.ScreenUpdating = True
    
    End Sub
    Any help would be appreciated.
    Last edited by zero635; 11-12-2008 at 10:32 PM. Reason: Solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1