+ Reply to Thread
Results 1 to 13 of 13

Delete all rows containing "?"?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-18-2010
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    139

    Question Delete all rows containing "?"?

    Hi all,

    I have a dataset of over 10k rows of URLs.

    I want to delete all rows containing query strings (e.g. https://xyz.com./example/example?abc).

    In other words, I want to remove all rows containing the question mark character (?). I tried doing a "Filter", but Excel interprets the "?" character!

    Thanks,

    Z

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    Let's say that the string is in A2, you could use... =IF(ISNUMBER(SEARCH("~?",A2)),1,0) in another cell then use a filter to group all the 1s together then delete them in a batch.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    BTW, you can apply a filter to the column by just using the ~? in the filter instead of using the formula I gave then the filter.

  4. #4
    Forum Contributor
    Join Date
    06-18-2010
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    139

    Re: Delete all rows containing "?"?

    Quote Originally Posted by Sam Capricci View Post
    BTW, you can apply a filter to the column by just using the ~? in the filter instead of using the formula I gave then the filter.
    [S]Hi, this doesn't work for me, unfortunately - it doesn't hide rows that CONTAIN "?" character.[/S]
    Ignore the above. It DID work after all !

    You can add multiple conditions to filters, can you?

    I now also want to exclude rows that contain a specific work like "apples"..
    Last edited by zudecke; 09-20-2021 at 04:21 AM.

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    I did an example for you with a filter and hiding the rows with the ?

    You can add other filters too by using and / or for additional restrictions.
    Attached Files Attached Files

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    Plus, I'd like to note that your post title says to delete all rows... but if you don't use the formula I gave you in post #2 or another formula and then sort to group all those with a 1 together then delete those rows, you'll need VBA to actually delete rows with those "?" in them. Formulas can't delete rows.

  7. #7
    Forum Contributor
    Join Date
    06-18-2010
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    139

    Question Re: Delete all rows containing "?"?

    Hi Sam

    Thanks SO much for your help and for taking the time to formulate an example spreadsheet !

    I like the proposal for using the filters, but I can't seem to work out how to add multiple filters.

    I'd like to hide (or, ideally, delete - but I can do that manually) all rows:
    - Containing: "?"
    - Containing: "stringxyz"
    - Containing: "string123"

    Etc

    I can't seem to use filters for this.

    Thanks,

    Z

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    my version of excel (for Apple) does not have the ability to filter on three variables but I believe the MS versions do allow for three variables.
    So I'm re-uploading the workbook with the filter applied for two variables, the ~? and string123. Just select to filter by: does not contain ~? and next filter is AND does not contain string123, if you have the ability to apply a third filter then also AND does not contain stringxyz.

    Using the reverse for deleting, filter on contains ~? and contains string123 (and if you can select a third) and contains stringxyz, then when all are visible, highlight those rows and delete them.

    If you can only apply two filters you could apply those two, then delete the selected rows you don't want then apply the third filter and delete those rows.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    06-18-2010
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    139

    Re: Delete all rows containing "?"?

    Quote Originally Posted by Sam Capricci View Post
    my version of excel (for Apple) does not have the ability to filter on three variables but I believe the MS versions do allow for three variables.
    So I'm re-uploading the workbook with the filter applied for two variables, the ~? and string123. Just select to filter by: does not contain ~? and next filter is AND does not contain string123, if you have the ability to apply a third filter then also AND does not contain stringxyz.

    Using the reverse for deleting, filter on contains ~? and contains string123 (and if you can select a third) and contains stringxyz, then when all are visible, highlight those rows and delete them.

    If you can only apply two filters you could apply those two, then delete the selected rows you don't want then apply the third filter and delete those rows.
    Hi Sam - many thanks again.

    FYI - My Excel supports only two conditional filters also.

    I think I'd need a mechanism that is more flexible. I have over 20k rows or something and need to apply A LOT of filters / remove a lot of rows.

    I need to identify/remove rows based on the characters in 1st column...

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.97.2 for Mac MS 365
    Posts
    8,708

    Re: Delete all rows containing "?"?

    Ok, about the last one I can think of without referring you to VBA is to do it with an if statement.
    so I put this if statement in col B that will return a 1 if it encounters ? or stringxyz or string123 and a 0 otherwise.

    =IF(OR(ISNUMBER(SEARCH("~?",A2)),ISNUMBER(SEARCH("string123",A2)),ISNUMBER(SEARCH("stringxyz",A2))),1,0)
    you can extend the if or statement to contain other content.
    then filter on col B to remove all the rows that contain a 1.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    06-18-2010
    Location
    London
    MS-Off Ver
    Excel 365
    Posts
    139

    Re: Delete all rows containing "?"?

    This is a fabulous proposal - I couldn't even conceptualise how best to attack this, so thanks for opening my brain to it.

    I'll try and tweak the IF statement to capture all the bits I want excluded
    Last edited by AliGW; 10-04-2021 at 05:02 AM. Reason: PLEASE don't quote unnecessarily!

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,792

    Re: Delete all rows containing "?"?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  13. #13
    Registered User
    Join Date
    09-23-2021
    Location
    New York
    MS-Off Ver
    2016
    Posts
    7

    Re: Delete all rows containing "?"?

    This may be done without any programming:
    1. Turn on Filter in the Sort & Filter group on the Home tab of the ribbon.
    2. Select Text Filters > Contains... from the filter menu in the relevant column.
    3. Click OK after typing Search in the box.
    4. Only the rows containing Search should now be visible.
    5. Delete the rows in question.

+ 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: 35
    Last Post: 01-13-2016, 02:16 AM
  2. [SOLVED] Delete Rows if a cell does not equal "Finished" or "Complete"
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-27-2013, 12:40 PM
  3. [SOLVED] Macro or vba to delete rows with "0" zero or "#"
    By ROHAN999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2013, 03:42 PM
  4. [SOLVED] Delete Rows FROM "X" UNTIL "Y" appears
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-08-2012, 07:47 PM
  5. Delete rows in the result of formulas "OK" n column "J"
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2012, 10:08 AM
  6. Excel 2007 : Delete rows containing "NA" in column "A"
    By grsnipe in forum Excel General
    Replies: 4
    Last Post: 08-16-2011, 06:57 AM
  7. How to delete rows when List toolbar's "delete" isnt highlighted?
    By Linda in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-26-2005, 05:15 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