+ Reply to Thread
Results 1 to 3 of 3

Delete empty rows from a sheet

  1. #1
    Registered User
    Join Date
    04-28-2006
    Posts
    14

    Delete empty rows from a sheet

    Hey could anybody help me with a script for deleting a row from a sheet if its second column is empty?

    I would appreciate it, Ben

  2. #2
    Registered User
    Join Date
    04-21-2006
    Posts
    61

    something like this... will prob need some tweaking, I'm not an expert either!

    rnum = 'insert start row number here

    Range("A" & rnum).select
    while activecell <>""
    do
    if activecell.offset(0,1) = "" then
    entirerow.delete
    else
    rnum = rnum + 1
    end if
    Range("A" & rnum).select
    loop until activecell = ""
    Wend


    Quote Originally Posted by bm4466
    Hey could anybody help me with a script for deleting a row from a sheet if its second column is empty?

    I would appreciate it, Ben

  3. #3
    Ron de Bruin
    Guest

    Re: Delete empty rows from a sheet

    Hi bm4466

    Try
    http://www.rondebruin.nl/specialcells.htm

    Sub DeleteBlankRows_2()
    'This macro delete all rows with a blank cell in column B
    'If there are no blanks or there are too many areas you see a MsgBox
    Dim CCount As Long
    On Error Resume Next

    With Columns("B") ' You can also use a range like this Range("A1:A8000")

    CCount = .SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Count

    If CCount = 0 Then
    MsgBox "There are no blank cells"
    ElseIf CCount = .Cells.Count Then
    MsgBox "There are more then 8192 areas"
    Else
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End If

    End With

    On Error GoTo 0
    End Sub


    --
    Regards Ron De Bruin
    http://www.rondebruin.nl



    "bm4466" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hey could anybody help me with a script for deleting a row from a sheet
    > if its second column is empty?
    >
    > I would appreciate it, Ben
    >
    >
    > --
    > bm4466
    > ------------------------------------------------------------------------
    > bm4466's Profile: http://www.excelforum.com/member.php...o&userid=33949
    > View this thread: http://www.excelforum.com/showthread...hreadid=548594
    >




+ 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