+ Reply to Thread
Results 1 to 8 of 8

Delete entire row in table if cell in column P contains any value (numbers or text)

  1. #1
    Registered User
    Join Date
    02-21-2011
    Location
    Australia
    MS-Off Ver
    MS Office 2016 on Windows 10
    Posts
    42

    Delete entire row in table if cell in column P contains any value (numbers or text)

    Hi I have a problem and cannot seem to find a suitable solution anywhere.

    I have a table (dynamic named range "datalog") Information is pasted from another source - as text.

    I would like to delete the "entire row" if a value (text or numbers) is displayed in column P. Essentially only leaving the rows with no data left in column P.

    What is the most efficient way of doing this in VBA. (as I have to automate this procedure)

    Data sets could be quite large.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    Hi BuntyMac,

    Try this (though initially on a copy of your data as the results cannot be undone if they're not as expected):

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    02-21-2011
    Location
    Australia
    MS-Off Ver
    MS Office 2016 on Windows 10
    Posts
    42

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    Thanks Robert.

    Unfortunately This deletes the blanks leaving the cells with value only.... Am I doing something wrong?

    I have attached a copy of the file
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    Am I doing something wrong?
    No just my code I read your request the wrong way around. Try this from the sheet is question (again on a copy of your data):

    Please Login or Register  to view this content.
    HTH

    Robert

  5. #5
    Registered User
    Join Date
    02-21-2011
    Location
    Australia
    MS-Off Ver
    MS Office 2016 on Windows 10
    Posts
    42

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    Robert,

    Thanks for taking the time and effort to solve this problem. It woks perfectly.

    Much appreciated.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    You're welcome. If you could mark the thread as solved it would be appreciated.

    Thanks,

    Robert

  7. #7
    Registered User
    Join Date
    02-21-2011
    Location
    Australia
    MS-Off Ver
    MS Office 2016 on Windows 10
    Posts
    42

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    Hi Robert,

    When I apply your macro to the real data - where the data is formatted as a "TABLE"

    It does not delete all rows where there is data in column 'P'

    If I convert the TABLE back to a range - The macro works perfectly.

    Any thoughts?

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Delete entire row in table if cell in column P contains any value (numbers or text)

    As far as I know "Table" is a somewhat protected area where one can delete singel rows but trying to do so for a number of rows is a "no no" as you found out.

    If the layout of your working file is like the uploaded file one can also use autofilter to find rows in P column with value. Something like this perhaps that convert a table to a range filter and delete and sets range back to a table.

    Please Login or Register  to view this content.
    Alf

+ 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. Replies: 1
    Last Post: 11-23-2015, 03:58 PM
  2. [SOLVED] Delete or hide entire column if top cell is blank
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2014, 12:59 PM
  3. [SOLVED] If Or statement to check cell text and delete entire row if text is found
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2013, 11:46 AM
  4. [SOLVED] Delete entire column if it does not contain a cell highlighted yellow
    By boorama in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-14-2013, 03:13 AM
  5. Macro (Delete Entire row Cell in column R is empty)
    By andrewvt in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2011, 07:06 AM
  6. Delete an entire row if a cell in Column D does not contain 01
    By ThirstyFire in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2011, 08:54 AM
  7. If cell in column B is blank, delete entire row
    By davehunter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2007, 06:38 AM

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