+ Reply to Thread
Results 1 to 11 of 11

Changing colours of Part of string

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    68

    Changing colours of Part of string

    I have a conditional formula which gives a value based on what the User specifies.
    Example of formula is:
    =IF($B$1=0,"CONTACT PERSON - OPTIONAL",IF($B$1=5,"CONTACT PERSON (FINANCE ONLY) - MANDATORY",""))
    If the result of the string is " CONTACT PERSON (FINANCE ONLY) - MANDATORY " then
    - word MANDATORY (not the whole string) should be in RED
    - words (FINANCE ONLY) should be in BLUE
    - remaining string should be left in BLANK
    Not intending to use VBA.
    Is this possible? Please help

    Thanking in advance.

    Rgds
    Dhiresh

  2. #2
    Registered User
    Join Date
    12-30-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Changing colours of Part of string

    Hi there,

    Pretty sure that without VBA this isn't going to happen. Have a Google - there seems to be a few VBA solutions out there.

    HTH,

    FermentedR

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Changing colours of Part of string

    You could only do that with VBA - a formula would not be able to do it.

    Pete

  4. #4
    Registered User
    Join Date
    12-13-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    68

    Re: Changing colours of Part of string

    Hi Pete,
    I am very new to Excel VBA. can you suggest a script I can use to get the results I need.

    rgds
    Dhiresh

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Changing colours of Part of string

    Sorry, my skills don't stretch that far. Maybe someone else will come in.

    Pete

  6. #6
    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: Changing colours of Part of string

    You could try somethink like this.

    Please Login or Register  to view this content.
    where 7 is the start position of a string and 10 is the number of characters to color.

    Alf

  7. #7
    Registered User
    Join Date
    11-27-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Changing colours of Part of string

    Try this:

    You may have to modify based on which column your highlight macro needs to work for and also if I got the length of your respective strings identical to what you have.

    Please Login or Register  to view this content.
    Let me know.

    Thanks,

    T
    Last edited by arlu1201; 03-04-2013 at 05:42 AM. Reason: Code tags not php tags.

  8. #8
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Changing colours of Part of string

    One more, see attachment, code courtesy of "jindon";
    However it seems that "characters(..., ...).Font.Color" only works if the text in column C is an actual value, not the result of a formula?
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-27-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Changing colours of Part of string

    Ya, you're right, it only works when it is text, with my code you would have to do a paste values into a new column before it would work.

  10. #10
    Registered User
    Join Date
    12-13-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    68

    Re: Changing colours of Part of string

    HI..

    I like to thx all who have given valueable assistance in this matter. I will try your suggestions

    Rgds
    Dhiresh

  11. #11
    Registered User
    Join Date
    12-13-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    68

    Re: Changing colours of Part of string

    Hi All,
    many thx for your suggested VBA to change colours of strings. I have adapted it for my purpose.

    It is appreciated.

    Kind Rgds
    Dhiresh

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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