+ Reply to Thread
Results 1 to 2 of 2

delete entire rows

Hybrid View

  1. #1
    Registered User
    Join Date
    01-26-2007
    Posts
    2

    delete entire rows

    Hi, I've my spreadsheet looks like this below. I would like to delete every row that has blank cells. I've googled around and there are loads of scripts that supposedly do this, but none of them work. I should say, I am an absolute programming newbie, but I would like to learn and get better.
    I have one request for the kind soul that would volunteer to post a solution: could you include line-by-line instructions about what every single command in your script does? To compare this to a car, I would really, really like to know where the battery is, what it does and how it relates to the carburator and the spark plus and so on, rather than just put the key in the ignition and drive off....
    I'm very grateful for your help!
    Yours,
    Simon

    10/3/01 0.69 0.6943 1.4402
    10/4/01 0.7 0.6979 1.4329
    10/5/01 0.7 0.6985 1.4317
    10/8/01
    10/9/01 0.7 0.6986 1.4314
    10/10/01 0.7 0.6994 1.4298

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    The following will delete all rows where there is no data in the B column

    Sub deleteRows()
    Dim i As Long ' declares i as a long integer variable
    Dim lRow As Long
    
    lRow = Cells(Rows.Count, 1).End(xlUp).Row ' determines last row with data in 1st column
    'Cells(rows.count) determines the highest row number
    ' .End(xlUp) finds the last row with data
    ' .Row grabs the row number
    
    For i = lRow To 2 Step -1 'loops through rows from the bottom up
        If Cells(i, 2) = "" Then 'checks to see if the B column in the current row is blank
            Cells(i, 2).EntireRow.Delete 'if B cell is blank, delete the row
        End If '"closes" the if statement
    Next i 'loops to next i (row)
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to delete rows
    By oakman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2008, 08:19 AM
  2. Compare & Delete Rows
    By DB91 in forum Excel General
    Replies: 4
    Last Post: 11-14-2007, 12:12 PM
  3. Delete Rows Based On Cell Contents
    By aapke in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2007, 08:14 PM
  4. How to loop through worksheet and delete rows based on criteria
    By rgrogan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-20-2007, 05:28 PM
  5. Delete rows based on specific criteria
    By Archana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2007, 05:00 AM

Tags for this Thread

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