+ Reply to Thread
Results 1 to 8 of 8

VBA to Modify Conditional Formatting Text

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    VBA to Modify Conditional Formatting Text

    Hi,
    Is it possible to use VBA to modify conditional format text? For example, if the text is "xxx" change it to "yyy". This is the text value that triggers the conditional format. (Highlight Cells with Text that contains...) Any/all ranges on the sheet where it occurs.
    Thank you.
    Last edited by ker9; 05-27-2018 at 09:25 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA to Modify Conditional Formatting Text

    The quickest way is just record a macro to do that. Start the recorder giev the macro a name and press Ctrl + H to open the find and replace box, enter the values and run it.
    then stop the macro recorder.
    Take a look at the vba code that has been generated and you've got an idea how it works and can edit at will.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: VBA to Modify Conditional Formatting Text

    When you do that it records every single conditional format that exists as well as the one that you change. It's very specific to cell, etc. I was trying to find a way to use modify but really struggling with it.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA to Modify Conditional Formatting Text

    Misunderstood; take a look at this link, maybe it will put you on the right track
    https://support.microsoft.com/en-us/...you-use-vba-in

  5. #5
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: VBA to Modify Conditional Formatting Text

    It would appear that you can format the appearance but I cannot find a method to modify the text.

    https://msdn.microsoft.com/en-us/vba...n-object-excel

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA to Modify Conditional Formatting Text

    True, you do not and cannot modify text using Conditional formatting. The word says it; conditional formatting, change of text is not a condition

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA to Modify Conditional Formatting Text

    Why don't you attach a sample file with what you have and what you want.
    You have to grasp the essential difference between conditional format and a cell content.

    For example when you put a date into a cell you can format it to show day name month name year and everything but the value is still an unchanged date
    The same with conditional format

    if you want the cell containing xxx to color blue and zzz to color green that is the only thing conditional format does.
    you have to manually or though another process change the content of that cell from xxx to zzz

    So what you do is write macro that will check all the cells within a range that have the value xxx and change it to zzz the conditional format if applied to that range will change accordingly

    Hope I have been able to explain my thoughts in a way that they help you solve this

  8. #8
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: VBA to Modify Conditional Formatting Text

    To be clear, I don't want to modify the text in the cell that is being conditionally formatted, I want to modify the text string in the conditional format rule.

    This is a small (relevant) portion of what you get when you record a macro.
    Where you see "CHANGE THIS TEXT", that is what I want to change. I need to change it in 100s of rules but I'm testing on 1 cell at the moment.

    Please Login or Register  to view this content.
    CF.PNG
    This does nothing
    Please Login or Register  to view this content.
    Last edited by ker9; 05-28-2018 at 09:41 AM. Reason: add screenshot

+ 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. Can you modify the range (using a Sub) for an existing conditional formatting rule?
    By sam.schardt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2016, 02:44 PM
  2. [SOLVED] How to modify conditional formatting to ignore specific values
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2015, 07:44 AM
  3. Formatting Cells with Date or Text Values in a Conditional Formatting Formula
    By Phil Hageman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-15-2014, 09:36 AM
  4. Replies: 0
    Last Post: 03-13-2013, 12:05 PM
  5. Modify Conditional Formatting
    By jamie.c in forum Excel General
    Replies: 15
    Last Post: 07-24-2009, 04:45 AM
  6. Modify a conditional formatting macro
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2009, 04:50 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