+ Reply to Thread
Results 1 to 8 of 8

Macro that clears cell contents on criteria

  1. #1
    Registered User
    Join Date
    06-22-2017
    Location
    United States
    MS-Off Ver
    2010
    Posts
    16

    Macro that clears cell contents on criteria

    Hi everyone. I posted a question yesterday and got an answer that worked.I am not super knowledgable in VBA and would like to write a macro that clears cell contents of a range if they don't contain a specific string.
    Excel example 2.PNG

    So if you look at the image, you'll see that it's a bunch of gibberish. I want to be able to highlight from the second row all the way to the right and all the way down, then run a macro that clears all cells within my selected range which do not end in "US Equity."

    Can this be done? Really appreciate the help.

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Macro that clears cell contents on criteria

    Try this code:
    Please Login or Register  to view this content.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro that clears cell contents on criteria

    This looks doable. However, can you please provide a worksheet with some dummy data too test on?

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Macro that clears cell contents on criteria

    Something like this perhaps....
    Please Login or Register  to view this content.
    Last edited by sintek; 06-23-2017 at 09:01 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro that clears cell contents on criteria

    I can't use selection to work backwards which is what I'd need for this to work, however this does the job for a sheet

    Please Login or Register  to view this content.
    Last edited by PFDave; 06-23-2017 at 09:04 AM.
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

  6. #6
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro that clears cell contents on criteria

    If you just want to clear the contents and not delete then

    Please Login or Register  to view this content.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Macro that clears cell contents on criteria

    @ PFDave

    OP requires cell to be cleared...
    run a macro that clears all cells within my selected range
    Edited:
    To early, prior to other code posted

  8. #8
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro that clears cell contents on criteria

    Quote Originally Posted by sintek View Post
    @ PFDave

    OP requires cell to be cleared...


    Edited:
    To early, prior to other code posted
    Got a version for that too

    I like to speculate as well

+ 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. Need Macro that clears data from cell but does not delete the content
    By rscottland in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2017, 11:27 PM
  2. [SOLVED] VBA Code that Clears contents of specific column in row
    By Jamidd1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 07:49 AM
  3. Clear cell macro clears other cells not recorded
    By bryden2008 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2015, 02:03 PM
  4. Navivgation bar that activates selected sheet, then clears contents of the bar
    By jkindustries in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-24-2015, 08:53 AM
  5. [SOLVED] Macro which clears contents below X text until it encounters Y text
    By SF1eagles in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-04-2014, 04:16 PM
  6. Macro that clears contents of all cells of certain colour (colour 35) in all sheets
    By Hanskubansku in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 07:33 AM
  7. Macro clears contents and my formula references
    By moike in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-19-2006, 01:04 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