none
changing the font color of a text string using VBA RRS feed

  • Question

  • I  have an Excel VBA application that performs analysis of MS Project schedules, with the analysis results being built and output to an excel spreadsheet. Some of the analysis results in the concatenation of a predefined text string with data from the project schedule. Based on the analysis the text string used will represent either a valid or invalid condition (there are about 10 different pairings of these messages). What I'd like to do is color code the text string as either red or green based on it's representation of either the valid or invalid condition.  The resulting spreadsheet consists of 23 tabs with specific categories of data. 

    I know I can change the font color of a specific cell's content by looping thru the cells, looking for the valid/invalid character string and then adjusting the font for the string with in the cell.  

    Is there a function that can be used to set the color of the text string prior to it being concatenated into the field and written to the results spreadsheet?

    Any suggestions would be appreciated.

    Dan

    Thursday, February 13, 2020 3:44 PM

All replies

  • Hi Dan,

    I'm afraid it's difficult to set the different color to the text string before concatenating them.
    Can't we color them after concatenation?  Toward that goal, we need to know how is the text string.
    Could you explain the difference between the original string and the added analysis result string?

    Regards,

    Ashidacchi -- http://hokusosha.com

    Thursday, February 13, 2020 11:11 PM
  • Hi Ashidacchi,

    Thanks for responding.  After reviewing some of the other posts on the subject i.e. changing the text color (most were character by character), I've decided to go a simpler route. instead of highlighting any text by font color, I'm just coloring the cell's boundary lines as content is being added to the various tabs in the spreadsheet..

    As to your original question: the source text string is free form text entry which depending on other conditions may have to include one or more specific topics, each of which is delimited by a specific tags. If the condition for specific content exists and the string is either blank or doesn't include the required tag, the text would be added to the original string would specify an error related to the missing content, the error text would be highlighted in red, if the required "tag" was found in the original string, a different text string would be added to the original string which this text being highlighted in green. all other text would remain the default black.

    The changing of the font color is still something I'd like to play with, but the cell border highlighting meets the need.

    Dan

    Friday, February 14, 2020 2:27 PM