+ Reply to Thread
Results 1 to 6 of 6

Possible use of VBA to clear cell content if a search term is found

  1. #1
    Registered User
    Join Date
    10-26-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    19

    Lightbulb Possible use of VBA to clear cell content if a search term is found

    Hi Everyone,

    I've been using this board for a while and learnt a lot thanks to many of your expertise and skill sets. I have searched these boards but have been unable to find a solution to my problem; hopefully something someone can help with?

    Key Points:
    1. I have a spreadsheet which consists of a number of tabs (7 in total)
    2. I am copying data from reports (from a .txt file) into column A of each tab (i.e. reportOne.txt will be copied into tab 1 column A, reportTwo.txt will be copied into tab 2 column A).
    3. I then have other reports that are generated at a later date and these will be used to populate column B in each tab (i.e. reportOne_v2.txt will be copied into tab 1, column B etc.)
    4. I am then comparing the two columns on a row-to-row basis (as the structure and contents should be exactly the same). Code that I am using (which works fine) is:
      Please Login or Register  to view this content.
    5. This formula is placed in Column C of each tab and copied/dragged to the last row containing data


    My Problem:
    1. The reports contains rows of data that I do not want to compare (i.e. I do not want to code above to be present in row C).
    2. What I have been doing is looking for search terms using a filter, selecting these rows and then manually removing the formula in Row C.
    3. Some reports run into thousands of rows, although many of the search terms have similarities and so the filter works fine, although this method is slow and inefficient and I have a 20 min time-frame to complete the whole task.


    Ideal solution:
    1. Would it be possible to have pre-defined search terms on a tab-by-tab basis that clears the content in column C if the search terms are matched?
    2. Possibly something we can do using VBA?
    3. Ideally I would like a button or to run a Macro that clears the content of column C if a row in column A finds a row that contains for example ("machine date/time...")

    By doing the above it will drastically reduce my manual work and ensure I complete this task within the set time-frame.

    Thanks and kind regards,

    Sam
    Attached Files Attached Files
    Last edited by s_bruno1; 05-17-2017 at 06:35 AM. Reason: Added attachment and grammar

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Possible use of VBA to clear cell content if a search term is found

    Try this:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    10-26-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    19

    Re: Possible use of VBA to clear cell content if a search term is found

    Works like a charm.

    Thanks Olly very much

  4. #4
    Registered User
    Join Date
    10-26-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    19

    Re: Possible use of VBA to clear cell content if a search term is found

    Olly,

    Sorry just one more question:

    Is it possible to filter and remove the content in cell C by using a wildcard character for rows that change very slightly. For example, I have the following in my master spreadsheet:

    DB Name AAA Machine Date/Time 11/05/2017 14:01 Proc Date 09/01/2017 Page 4
    DB Name AAA Machine Date/Time 11/05/2017 14:01 Proc Date 09/01/2017 Page 5
    DB Name AAA Machine Date/Time 11/05/2017 14:01 Proc Date 09/01/2017 Page 6

    The array requires an exact match but as you can see the page number increments. Would it be possible to do a search on just the first part of the cell which is constant throughout:

    "DB Name AAA Machine Date/Time"

    Thanks,

    Sam

    Edit: Not to worry, I kind of answered my own question:

    "DB Name AAA Machine Date/Time*" - Works fine

    Cheers.
    Last edited by s_bruno1; 05-17-2017 at 08:31 AM. Reason: updated content

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Possible use of VBA to clear cell content if a search term is found

    Yes, just include * as a wildcard - e.g.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-26-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    19

    Re: Possible use of VBA to clear cell content if a search term is found

    Thanks, we posted at the same time and came to the same solution.

    Thanks again Olly for your help.

    Thread marked as solved and reputation +1 done.

+ 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] Clear content referencing another cell's same content
    By papusale in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-08-2015, 05:21 AM
  2. [SOLVED] Search content from cell A1 in Sheet2 and select the content found
    By excelcandy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2013, 06:45 PM
  3. [SOLVED] Formula to display cell if the text content partially matches a search term
    By Avestron in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2013, 04:07 AM
  4. IF same CONTENT FOUND IN CELL A THEN DELETE CONTENT IN B,C or D
    By mecutemecute in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2013, 01:16 AM
  5. [SOLVED] Search for value in range and clear value when found
    By 3foo3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2013, 08:27 PM
  6. Replies: 4
    Last Post: 05-12-2011, 02:25 PM
  7. Replies: 3
    Last Post: 07-12-2006, 10:15 AM

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