Consulting

Results 1 to 2 of 2

Thread: delete blank rows in excel using VBA

  1. #1

    delete blank rows in excel using VBA

    How to delete blank rows in excel using VBA?

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,137
    Location
    Welcome to VBAX Alqahtanir. You could try the following code
    Public Sub DeleteBlankRows()
      Dim SourceRange As Range
      Dim EntireRow As Range
      Set SourceRange = Application.Selection
      If Not (SourceRange Is Nothing) Then
        Application.ScreenUpdating = False
        For I = SourceRange.Rows.Count To 1 Step -1
             Set EntireRow = SourceRange.Cells(I, 1).EntireRow
             If Application.WorksheetFunction.CountA(EntireRow) = 0 Then
                 EntireRow.Delete
             End If
        Next    
        Application.ScreenUpdating = True
      End If
    End Sub
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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