+ Reply to Thread
Results 1 to 6 of 6

Delete Empty Rows

Hybrid View

  1. #1
    Registered User
    Join Date
    10-26-2006
    Posts
    26

    Delete Empty Rows

    Does anyone know how I can delete empty rows using VBA?

    Thanks in advance.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Link should help

    http://www.ozgrid.com/VBA/VBACode.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-26-2006
    Posts
    26
    THanks for your reply, but that code isn't working for me. I am using the following code from the example:

     Sub DeleteBlankRows2()
    'Deletes the entire row within the selection if _
     some of the cells WITHIN THE SELECTION contain no data.
    On Error Resume Next
    Selection.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete
    On Error GoTo 0
    End Sub


    But I am having to step through the worksheet manually. How can I loop through this quickly?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    On Error Resume Next
    ActiveSheet.UsedRange.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    If there are empty cells on your spreadsheet, this will delete those rows.
    Sub DeleteBlankRows2A()
    'Deletes the entire row of any cell that contain sno data.
    On Error Resume Next
    ActiveSheet.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0
    End Sub

  6. #6
    Registered User
    Join Date
    10-26-2006
    Posts
    26
    Mike

    When I use your code, it doesn't do anything. Is there something that I am doing wrong?

+ Reply to Thread

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