Consulting

Results 1 to 4 of 4

Thread: Solved: Delete row based on first cells contents?

  1. #1

    Solved: Delete row based on first cells contents?

    I'm looking for some code that would search down column A and where each cell equals "N" delete the row. Thanks in advance because this forum always delivers!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long

    With Application

    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    End With

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = LastRow To 1 Step -1

    If .Cells(i, "A").Value = "N" Then .Rows(i).Delete

    Next i

    End With

    With Application

    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    That works wonderfully as always XLD. Thanks

    How can i add another step to go to the next page named "Locations" and do the same things by deleting blank rows by going down column "B".

  4. #4
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    220
    Location
    Add this to the sub right before you set the screen updating back to True note: this will delete all blanks in column B

    [vba]Worksheets("Locations").Range("B:B").SpecialCells(xlCellTypeBlanks).EntireR ow.Delete[/vba]
    "Intellectual passion occurs at the intersection of fact and implication."

    SGB

Posting Permissions

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