+ Reply to Thread
Results 1 to 19 of 19

Add font color, bold, italic to string

  1. #1
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Add font color, bold, italic to string

    Hello,
    I have this issue in years to enhance the string using If ...then function.
    I could use conditional formating for entire string, but I want to enhance
    string partically.

    For example: If A1=10, "This is correct","This is not correct"
    I like the string (answer) to be "This is correct"
    "This is not correct]"

    I know I can add color/bold/italic to a string in a cell but not string from the function.

    Is that possible using function or VBA?


    Thanks
    Last edited by Rocky2013; 04-13-2015 at 07:34 AM.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Add font color, bold, italic to string

    Does A10 contain a formula or a constant??
    Gary's Student

  3. #3
    Registered User
    Join Date
    01-09-2015
    Location
    Turket
    MS-Off Ver
    2013
    Posts
    64

    Re: Add font color, bold, italic to string

    I think, it is possible. Now, I could not use excel by my computer.But you can try save a macro.
    First of all, start macro for saving, after that write "This is correct" to a cell. Then, change it's color. And, stop macro.
    When you open the code, you will see what to do to change color of cells.

  4. #4
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    Hello Jakobshavn,
    A1 will be a formula, It is not necessory a number, but it could be a string. I just make up an example.
    I use the result in A1 to initate an error or message for the reader to be award the result in A1.

    Another example the formula can be liked this .... If(A1=10, "", "Incorrect, Please check the input.")
    if A10 is not 10, then I want the result to be ... Incorrect, Please check the input.

    If it is VBA, I like to have a real time without click a command button.

    Hello oglcngcmn,
    Macro recording does not work for me using a command button to run the code; unless if I can modify the code to eliminate
    the use of a command buuton if I know how.

    Thanks
    Last edited by Rocky2013; 04-12-2015 at 10:25 AM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    You cannot format the output from a formula. You can only apply formatting to sub-strings of text values. You could probably do it with VBA.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    Hello All,
    It seems complicate. What I am have been doing is to use conditional formating to highlight the entire string,
    I will continue to use this way.

    This request is a nice to have just to catch the attention on important text rather than reading the whole string.

    Maybe a new feature add to the next update of Excel.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Add font color, bold, italic to string

    Perhaps something like this could be a possible solution?

    Please Login or Register  to view this content.
    Not the best of code so there is certainly room for improvement if somebody has a better idea.

    Alf

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    @Alf: you could generalise it into a Worksheet Change event handler.

    Regards, TMS

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Add font color, bold, italic to string

    Hi TMS

    Yes much better but I would like to get it down to a few line of code. Perhaps if the OP hade 3 cell in his worksheet with text "This is", "correct", "not correct" with the propper font and color and just use cell1 & " " & "cell2 & " and cell1 & " " & cell3 in order to get the desired string.

    Alf

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    @Alf: Thanks for the feedback.

    OK, maybe a little shorter. Not sure I can it get it better than this:

    Please Login or Register  to view this content.

    Regards, TMS

  11. #11
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    I will use real time change VBA from TMS's code for immediate use but
    Alf'code using command button is also nice to have to service for other purpose.

    I thought I gave up on this, but your help is very appreciate. Both codes work.

    Thank you,

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    You're welcome. Thanks for the rep.

  13. #13
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    Hello,
    I already changed to "SOLVED". But last minute thought, what is the code to add a hyberlink to "Correct" and
    "incorrect" or the whole sentense because sometime I use If.. then to give the correct answer with a hyperlink
    to a web site fo getting the information.

    Thanks again

  14. #14
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    Hello,
    I already changed to "SOLVED". But last minute thought, what is the code to add a hyberlink to "Correct" and
    "incorrect" or the whole sentense because sometime I use If.. then to give the correct answer with a hyperlink
    to a web site fo getting the information.

    Thanks again

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    Don't know off the top of my head. Think it's a new question really and warrants a new thread, with maybe a little more detail about what the URL needs to look like, etc.

    Regards, TMS

  16. #16
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    I prefect just the word(s) not a whole sentense if possible. I did quick searched after I added SOLVED.
    I was thinking Do-it-myself, then I got lost with the codes. For the example, I would just use http://www.Yahoo.com
    and http://www.Google.com. The link will not have underline if possible. I can change them later.

    Thanks
    Last edited by Rocky2013; 04-13-2015 at 08:01 AM.

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    OK, I give in ...

    Please Login or Register  to view this content.

    Regards, TMS

  18. #18
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Add font color, bold, italic to string

    Thanks.
    This post is finally SOLVED.

    Regards,

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Add font color, bold, italic to string

    You're welcome.

+ 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. Using Bold and Italic on certain text in formula
    By pakida in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-27-2014, 07:53 PM
  2. Mouse rolls over to cell will change the tab color, font color and tp bold type
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-20-2013, 10:36 AM
  3. Bold, Underline and Italic greyed out
    By drgogo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2009, 09:30 AM
  4. Allow Bold & Italic in a textbox
    By LookingGood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2006, 04:45 PM
  5. [SOLVED] determining bold font in a string
    By william kossack in forum Excel General
    Replies: 2
    Last Post: 11-02-2005, 06:17 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