+ Reply to Thread
Results 1 to 19 of 19

Delete all cells except containing specific text

  1. #1
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Delete all cells except containing specific text

    Hi,

    I have a large excel file with thousands of columns.
    I want to keep all column headers plus only those cells which contain specific word. Rest of the cells should be deleted so that I am only left with column header and required cells below.

    Need your help guys.

  2. #2
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Delete all cells except containing specific text

    filter your data

  3. #3
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by carlmon View Post
    filter your data
    You mean filtering each column if I am not wrong, but there are thousands of columns which is a challenge.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Delete all cells except containing specific text

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Delete all cells except containing specific text

    Quote Originally Posted by myawan View Post
    You mean filtering each column if I am not wrong, but there are thousands of columns which is a challenge.
    You filter the entire data set, then you filter one column to the word you want. The entire data set will only show you this word.

    From there you can copy your data out to somewhere else, look at it where it is OR filter to everything but the word you want, delete the visible data and then remove the filter - you will be left with only the data you need.
    If things don't change they stay the same

  6. #6
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    I filtered entire data set, then filtered one column to the specified word.
    Now rest of the columns hide the required data.
    As expected I guess.

  7. #7
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Delete all cells except containing specific text

    I think that kind of proves that we do not have enough information about the issue to help.

  8. #8
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Sorry for the delay, sample file is attached.

    Here you can see two sheets, one is 'Before' which shows the raw data where I have to keep only those cells having the text '2G'.
    Second sheet contains required data after cleaning done.

    Hope it clarifies.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Delete all cells except containing specific text

    For future explanations.
    You don't have cells with text '2G'.
    You have cells where the last two letters/numbers of the cell values = 2G.
    Makes all the difference if you don't have an example workbook.
    Experience trumps academics every day of the week and twice on Sunday.

  10. #10
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by jolivanes View Post
    For future explanations.
    You don't have cells with text '2G'.
    You have cells where the last two letters/numbers of the cell values = 2G.
    Makes all the difference if you don't have an example workbook.
    Yes, in most of the cases '2G' is the last two letters of the cell value. But it can be elsewhere as well.
    So the key is the these two alphabets coming together in any cell warrants that cell to be kept and rest to be deleted.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Delete all cells except containing specific text

    Re: "Yes, in most of the cases '2G' is the last two letters of the cell value. But it can be elsewhere as well."
    Not in your attachment. There it only shows at the end.
    An attachment should be a representative workbook that has ALL possibilities so helpers don't have to do things over and over because things are being added/changed after.

  12. #12
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by jolivanes View Post
    Re: "Yes, in most of the cases '2G' is the last two letters of the cell value. But it can be elsewhere as well."
    Not in your attachment. There it only shows at the end.
    An attachment should be a representative workbook that has ALL possibilities so helpers don't have to do things over and over because things are being added/changed after.
    I would be more than happy if I get any solution based on the scenario shown in attachment.

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Delete all cells except containing specific text

    Smart move. Telling possible helpers that after spending their hard to come by free time on a solution that will need to be changed later.

  14. #14
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by jolivanes View Post
    Smart move. Telling possible helpers that after spending their hard to come by free time on a solution that will need to be changed later.
    I literally can't understand what is the problem here with you??? Your replies are spam and are not helping anyone.

    I have repeated multiple times that whatever people can support will be much appreciated since they are helping me for free and using their precious time.

    I am indebted for their time and not putting any conditions here.

  15. #15
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Delete all cells except containing specific text

    This formula-based proposal converts the data on the Before sheet into a table.
    On the after sheet the formula used to populate A2:F5 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  16. #16
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by JeteMc View Post
    This formula-based proposal converts the data on the Before sheet into a table.
    On the after sheet the formula used to populate A2:F5 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Thanks a lot for your time and effort! Much appreciated.

    Just a query, what if I want to add more columns since this seems to be working fine till column F? For additional columns, it is only returning first match.

  17. #17
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Delete all cells except containing specific text

    Please upload a sample file that illustrates the issue of only returning the first match for the additional columns.
    Let us know if you have any questions.

  18. #18
    Registered User
    Join Date
    09-02-2020
    Location
    Oman
    MS-Off Ver
    2013
    Posts
    9

    Re: Delete all cells except containing specific text

    Quote Originally Posted by JeteMc View Post
    Please upload a sample file that illustrates the issue of only returning the first match for the additional columns.
    Let us know if you have any questions.
    Thanks a lot I made it to work, just needed drag and drop in additional columns!!

  19. #19
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Delete all cells except containing specific text

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. [SOLVED] Macro to Delete rows from specific text until other specific Text
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-11-2021, 10:35 AM
  2. [SOLVED] Delete row if contains specific text
    By track85 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-02-2021, 01:03 AM
  3. Function to delete text from all cells that do not contain specific text values?
    By etwibell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2018, 03:56 PM
  4. [SOLVED] Counting cells with specific text excluding if date in specific cells
    By FraserMc97 in forum Excel General
    Replies: 2
    Last Post: 04-07-2017, 06:19 AM
  5. [SOLVED] Delete row with a specific text
    By Saturn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2016, 08:46 AM
  6. Delete Rows with specific text in specific column
    By love2waltz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2015, 10:16 AM
  7. Delete Columns if cells in row 5 has a specific Text
    By VKu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2015, 08:52 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