+ Reply to Thread
Results 1 to 5 of 5

how to delete rows in a table in excel

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    3

    how to delete rows in a table in excel

    Hi All,

    I have a requirement to delete a row in a table if few of the columns in the table doesn't contain data using a macro or VB code

    can anyone help me on this please.

    Thank you,
    mahi

  2. #2
    Registered User
    Join Date
    04-22-2013
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003/2007 & 2010
    Posts
    90

    Re: how to delete rows in a table in excel

    Million solutions, better post a workbook explaining your case in more detail

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: how to delete rows in a table in excel

    Hey mahi4tech..

    why don't you post some sample code. It will be easier to help you with the solution!

  4. #4
    Registered User
    Join Date
    05-07-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: how to delete rows in a table in excel

    Hi ,

    I have attached a sample excel with a table named "Table2" with 7 columns

    my requirement is i need to delete a row in my table if say column 1,2 and 4 doesnt have any data in their respective cells
    req.png

  5. #5
    Registered User
    Join Date
    04-22-2013
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003/2007 & 2010
    Posts
    90

    Re: how to delete rows in a table in excel

    Find attached, should get you started. Not the neatest approach, perhaps somebody has cleaner coded method?

    Code:
    Sub DeleteRowsFromTable()
    
    Dim tbl As Range
    Dim r, c, rend As Integer
    
    Set tbl = ActiveSheet.ListObjects("Table1").Range
    rend = tbl.Rows.Count
    r = 1
    
    Do While r <> rend + 1
    continueonsamerow:
        Debug.Print Cells(r, 3).Address & " value = " & Cells(r, 3).Value & vbTab & Cells(r, 6).Address & " value = " & Cells(r, 6).Value
        If Cells(r, 3).Value = "" Or Cells(r, 6).Value = "" Then
            tbl.Range(Cells(r, 1), Cells(r, 9)).Delete
            rend = rend - 1
            GoTo continueonsamerow
        End If
        r = r + 1
    Loop
    
    MsgBox "Done"
    
    End Sub
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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