Consulting

Results 1 to 3 of 3

Thread: Solved: Delete empty rows

  1. #1

    Solved: Delete empty rows

    I know that there are certain rows which don't have any value in any cell.
    I am trying to delete an empty row.

    How can I correct this program in VBA: -

    [VBA]
    Sub test()

    For rownum = 1 to EndofRowCalculatedFromA65536
    For colnum = 1 to 256

    If Cells(rownum, colnum) <> vbnullstring Then

    Else
    Delete Entirerow
    End If

    Next colnum
    Next rownum

    End Sub[/VBA]

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

    Sub test()
    Dim Lastrow As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With ActiveSheet

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

    If Application.CountA(.Rows(i)) = 0 Then

    .Rows(i).Delete
    End If

    Next i
    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

  3. #3
    Yes, it worked. Many thanks, Bob

Posting Permissions

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