+ Reply to Thread
Results 1 to 5 of 5

Deleting empty rows

  1. #1
    Registered User
    Join Date
    12-06-2005
    Posts
    3

    Exclamation Deleting empty rows

    I need to delete empty rows but since there are pretty many I want to do a loop. How do I do that? The entire column should be deleted if row 56 equals 0 and the columns are D to DS. Any suggestions?

  2. #2
    Norman Jones
    Guest

    Re: Deleting empty rows

    Hi Edward,

    Try:

    '============>>
    Sub Tester()

    On Error GoTo 0
    Range("D56:DS56").SpecialCells(xlCellTypeBlanks). _
    EntireColumn.Delete
    On Error GoTo 0

    End Sub
    '<<============

    ---
    Regards,
    Norman



    "edward0380" <[email protected]> wrote
    in message news:[email protected]...
    >
    > I need to delete empty rows but since there are pretty many I want to do
    > a loop. How do I do that? The entire column should be deleted if row 56
    > equals 0 and the columns are D to DS. Any suggestions?
    >
    >
    > --
    > edward0380
    > ------------------------------------------------------------------------
    > edward0380's Profile:
    > http://www.excelforum.com/member.php...o&userid=29396
    > View this thread: http://www.excelforum.com/showthread...hreadid=491107
    >




  3. #3
    Norman Jones
    Guest

    Re: Deleting empty rows

    Hi Edward,

    I should have indicated that I have assumed that you want to delete
    columns, as in the body of your post, rather than rows, as suggested in the
    title and opening line.

    ---
    Regards,
    Norman



  4. #4
    Registered User
    Join Date
    12-06-2005
    Posts
    3
    Thanks! You are right, I want to delete the columns... But if row 56 is equal to 0 will it not be deleted, how do I solve this?

  5. #5
    Norman Jones
    Guest

    Re: Deleting empty rows

    Hi Edward,

    Try:

    '============>>
    Sub Tester3()
    Dim rng As Range
    Dim i As Long

    Set rng = Range("D56:DS56")

    For i = rng.Columns.Count To 1 Step -1
    With rng(i)
    If .Value = 0 Then
    .EntireColumn.Delete
    End If
    End With
    Next i

    End Sub
    '<<============


    ---
    Regards,
    Norman


    "edward0380" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Thanks! You are right, I want to delete the columns... But if row 56 is
    > equal to 0 will it not be deleted, how do I solve this?
    >
    >
    > --
    > edward0380
    > ------------------------------------------------------------------------
    > edward0380's Profile:
    > http://www.excelforum.com/member.php...o&userid=29396
    > View this thread: http://www.excelforum.com/showthread...hreadid=491107
    >




+ 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