+ Reply to Thread
Results 1 to 2 of 2

Deleting empty rows

Hybrid View

  1. #1
    Registered User
    Join Date
    02-15-2009
    Location
    NJ
    MS-Off Ver
    Excel 2003
    Posts
    8

    Deleting empty rows

    Hi,

    I'm trying to only delete the empty rows on a specific sheet, on the codition that if the former cell and latter cell both contain a value then to delete the empty row.

    Something just isn't right with my code (below) Any input would be greatly appreciated

    Sub Rwdelete()
    Dim i As Long
    Sheet4.Activate
    For i = 20000 To 2 Step -1
        If Not IsEmpty(Cells(i - 1, 1)) And Not IsEmpty(Cells(i + 1, 1)) Then Rows(i).Delete
    Next i
    End Sub
    Last edited by Rawlings99; 03-26-2009 at 08:13 PM. Reason: Solved

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting empty rows

    Hi,

    Untested but how about

    If Range("A1").Cells(i -1, 1) = "" AND Range("A1").Cells(i +1, 1) = "" Then
    Range("A1).Cells(i,1).EntireRow.Delete
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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