+ Reply to Thread
Results 1 to 4 of 4

Delete entire row, based on a table

Hybrid View

PingTing Delete entire row, based on a... 07-30-2021, 12:09 PM
HSV Re: Delete entire row, based... 07-30-2021, 05:43 PM
PingTing Re: Delete entire row, based... 07-30-2021, 05:52 PM
HSV Re: Delete entire row, based... 07-30-2021, 06:00 PM
  1. #1
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Delete entire row, based on a table

    hi. I have table ([Table1]) which covers columns A:M (number of rows are dynamic). I have found code to delete the table rows, but I want to delete the entire sheet row, based on the table rows.

    I want to delete all sheets rows in line with the table, except the first and last row (so I would be left with just the header row, the first row, and the last row).

    Here's some code that would do the table rows.

    For x = 1 to 5
    Sheet1.ListObjects("Table1").ListRows(2).Delete
    Next
    I've attached a sample sheet. So in the sample, I would want to delete the entire sheet rows from 9 to 33 (this is dynamic of course) and leave just the header row (row 7), the first row (row 8), and the row called "dummy row".
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    868

    Re: Delete entire row, based on a table

    If you are sure, change Select to Delete
    Sub hsv()
     With Sheets("master")
      .Rows(.ListObjects(1).DataBodyRange(2, 1).Row).Resize(.ListObjects(1).ListRows.Count - 2).select 'Delete
     End With
    End Sub
    Harry.

  3. #3
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Delete entire row, based on a table

    @Harry.

    Thank you so much. That worked perfectly. Really appreciate it.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    868

    Re: Delete entire row, based on a table

    Fine, you can also write it this way if you like.
    With Sheets("master").ListObjects(1)
      .parent.Rows(.DataBodyRange(2, 1).Row).Resize(.ListRows.Count - 2).delete
     End With

+ 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. Delete entire row based on certain condition
    By roberco30 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2017, 10:41 PM
  2. [SOLVED] delete entire active cells row/s only if thet all inside of a table (whatever table it is)
    By netanel99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-02-2017, 01:42 PM
  3. [SOLVED] Can't delete entire row based on condition in table range.
    By Tapyr in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-15-2016, 11:01 AM
  4. [SOLVED] VBA to delete entire row based on condition met
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-17-2014, 05:48 PM
  5. [SOLVED] Delete entire row based on 2 criteria
    By coopman64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2012, 03:38 PM
  6. Delete entire row based on criteria
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2011, 09:13 AM
  7. Delete Entire Row based on criterion
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2011, 08:40 PM

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