+ Reply to Thread
Results 1 to 17 of 17

macro to color all specific letters in a range of text

  1. #1
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    macro to color all specific letters in a range of text

    Hello,

    I'm trying to set up a macro to color all specific letters in a range of text in one cell. So for example the text ERFLEEWLEFDE, I want to give all the "E" a blue font color and font = bold.
    the macro code I came up with only colors the first "E" it finds.
    who can help me with some changes in the code to color all the "E" in the text.

    thanks in advance

    text in cell: ERFLEWLEFDE

    code so far:

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    Hello,

    I'm sorry,
    trying to fix it but it then the site is blocked..?

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: macro to color all specific letters in a range of text

    Try

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  4. #4
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    Hello,
    thanks for your help,
    it isn't working, it stuck on (If .Characters(k, 1) = "E" Then)
    error: runtime error 438. object doesn't support this property or method

  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: macro to color all specific letters in a range of text

    Hi.. Try this.. it will color the "e" character in the usedrange in column G in blue...

    Please Login or Register  to view this content.

    Ooops.. after this line..
    Please Login or Register  to view this content.
    Add this line to make the character be Bold..
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by apo; 02-14-2014 at 05:13 AM.

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: macro to color all specific letters in a range of text

    Quote Originally Posted by WillemB View Post
    it isn't working, it stuck on (If .Characters(k, 1) = "E" Then)
    Sorry about that, missed out .Caption.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    Thanks for your help

    it works!

  8. #8
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    It's Working

    Thanks for the help!

  9. #9
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: macro to color all specific letters in a range of text

    This will work now.. just needed to replace the "1" with the "j" variable..

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    dear Millz,

    the code is working nice,
    is it possible to select more letters in once? like the "E" and the "D" ant maybe other letters?

    thanks

  11. #11
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: macro to color all specific letters in a range of text

    Hi..
    Did you try my code..? I am pretty sure it does what you want..

    To select more letters.. just add the "Or" operator..

    Example:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    Hey Apo,

    I'am trying to put it in a toggle button like the code here:
    it gives an error; Next without for?
    can you help

    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: macro to color all specific letters in a range of text

    hi.. watching a movie right now.. ..

    but just quickly.. remove the first "Next f" and move the secondd "Next f" below the "End Select" statement.. thats a start anyway..

  14. #14
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    Hi,

    Not working yet, I will wait till end of the movie
    thanks

  15. #15
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: macro to color all specific letters in a range of text

    You can add more conditions like this:

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-08-2013
    Location
    the Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: macro to color all specific letters in a range of text

    It's working thanks,
    but if the value of the cells in column G is linked to another cell t gives error 1004 unable to get caption property of the characters class
    can you help me with this error

  17. #17
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: macro to color all specific letters in a range of text

    I don't think there's a way to highlight the letters if you are linking cell values. You must change them into values first.

+ 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. how to find a color in a row where the color is blue , if true fill with a specific text
    By jayakumar.chandran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 03:38 AM
  2. Macro to format row color in a range based on text value in column
    By toaksie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2012, 12:54 PM
  3. [SOLVED] Change text color of specific date range by macro in Excel
    By Morgan LeFay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2006, 02:55 PM
  4. how can i get EXcel to add up letters in a specific color?
    By lyssette in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2006, 02:10 PM
  5. count by specific text color in range of cell
    By Tii99 in forum Excel General
    Replies: 2
    Last Post: 04-04-2006, 04:58 AM

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