Consulting

Results 1 to 6 of 6

Thread: Solved: Excel 2003 - Delete rows with no values in Columns A thru E

  1. #1
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location

    Solved: Excel 2003 - Delete rows with no values in Columns A thru E

    I have a worksheet where Columns A thru J are used for data
    and I would like to delete rows when all the cells in Columns A thru E are empty. (approx 1,000 out of 15,000 rows meet that criteria)
    * Column J can be used as the last row reference.

    Edit: I need this to be done using VBA code

    Thanks

  2. #2
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Quote Originally Posted by frank_m
    Edit: I need this to be done using VBA code
    Yes because Excel Does Provide you with Filters

    [VBA]Sub deleteAtoE()
    Dim LastRow As Long
    With Sheet1
    LastRow = .Range("J" & Rows.Count).End(xlUp).Row
    For i = LastRow To 2 Step -1
    If .Range("A" & i).Value & .Range("B" & i).Value & _
    .Range("C" & i).Value & .Range("D" & i).Value & _
    .Range("E" & i).Value = "" Then
    .Rows(i).delete
    End If
    Next i
    End With
    End Sub[/VBA]
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  3. #3
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    Thanks shrivallabha

    that works nicely

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

    Sub DeleteBalanks()
    Dim Lastrow As Long
    Dim rng As Range

    Application.ScreenUpdating = False

    With ActiveSheet

    .Rows(1).Insert
    .Columns("F").Insert
    .Range("F1").Value = "Temp"
    Lastrow = .UsedRange.Rows.Count
    Set rng = .Range("F2").Resize(Lastrow - 1)
    rng.FormulaR1C1 = "=COUNTIF(RC[-5]:RC[-1],"""")=5"
    Set rng = .Range("F1").Resize(Lastrow)
    rng.AutoFilter Field:=1, Criteria1:="TRUE"
    On Error Resume Next
    Set rng = rng.SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    If Not rng Is Nothing Then rng.EntireRow.Delete
    .Columns("F").Delete
    End With

    Application.ScreenUpdating = True
    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

  5. #5
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Terrific XLD...no loops...
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  6. #6
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    Hi xld

    Thank you very much for writing that code for me. --> as shrivallabha said the fact that there is no looping is great. Definitely worth plenty of praise

Posting Permissions

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