+ Reply to Thread
Results 1 to 4 of 4

Format Macro to Clear Contents if Condition Met and Do Nothing Otherwise

  1. #1
    Registered User
    Join Date
    08-25-2020
    Location
    Tennessee, United States
    MS-Off Ver
    365 ProPlus
    Posts
    2

    Exclamation Format Macro to Clear Contents if Condition Met and Do Nothing Otherwise

    Hello! This is my first post here. I'm pretty familiar with Excel generally using the 365 package but I am new to the Macro function. For a report that I use daily, I want to find a way to make my macro clear part of the contents of a column if a condition is met and leave the rest of the data otherwise.

    I have attached an example of the data that I am looking at. Students (column A) are sorted by their Level (column B). My report lists the Honor designation (column C) for each student. I want to always remove the honors for students that have the level of GR or AG. For UG and AP students, however, I want the honor data to remain untouched. My data varies each day so I want to always achieve the same result where all GR and AG students have no honors listed.

    For this to be achieved, do I need to use an If/Then statement? Would you recommend any other work-around?
    Attached Files Attached Files

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

    Re: Format Macro to Clear Contents if Condition Met and Do Nothing Otherwise

    Please Login or Register  to view this content.
    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

  3. #3
    Registered User
    Join Date
    08-25-2020
    Location
    Tennessee, United States
    MS-Off Ver
    365 ProPlus
    Posts
    2

    Re: Format Macro to Clear Contents if Condition Met and Do Nothing Otherwise

    Alansidman,

    This worked perfectly for my example, thank you!

    If I want to use this as part of a larger macro that I have created. For the actual workbook, the honor is listed in column N and the level is in column J. If I include the above into the code I have created, can I simply add this directly above the "End Sub" at the end of the code? Because I would be including it within an existing macro, does this change any of the commands?

    Thank you for your reply, I already feel a lot closer to solving this problem that has been plaguing me for days!

    Excel_Student2020

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

    Re: Format Macro to Clear Contents if Condition Met and Do Nothing Otherwise

    You should be able to insert it directly, but you will need to change the ranges in the code and change the offset accordingly.

+ 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] vba clear contents and any format in specific columns
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-29-2017, 07:35 AM
  2. Clear cell contents of drop down box based on condition
    By Pami in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-29-2015, 12:05 PM
  3. [SOLVED] Can't Clear Cell Contents After Conditional Format
    By Speedy1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2012, 07:46 AM
  4. Macro that will clear contents of cell based on format of text in adjacent cell
    By judasdac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2012, 01:56 AM
  5. [SOLVED] Clear Cell Contents based on Number Format
    By lloydgodin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2012, 04:55 PM
  6. Clear Contents in Specific Rows via condition
    By Excel Newbie05 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-09-2008, 04:02 PM
  7. [SOLVED] Clear contents with condition
    By Vanna in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2006, 11:10 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