+ Reply to Thread
Results 1 to 2 of 2

VBA : Change font colour within a cell up to nth character

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    VBA : Change font colour within a cell up to nth character

    Hello,

    I have a tracker where I am trying to change the font colour in a cell up to the 10th character.
    Please Login or Register  to view this content.
    The code works for normal cells but the cells I would like it to work on (A3 - B50) are dates and the cell is formatted as "(mm) mmm : dd mmmm yyyy {dddd}" so when I enter "12/12/17" what is displayed is "(12) Dec : 12 December 2017 (Tuesday)". I cannot work out how to get the code to work on these cells. I think it has something to do with the actual text entered.

    I have attached a copy of the sheet with an example. I want all characters up to and including the ":" to be a different colour to the rest of the cell.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA : Change font colour within a cell up to nth character

    Marc

    You would only be able to do this if you replaced the value in the cell with the value as it's formatted.

    This code will do that but you won't be able to use the values from the formatted cells as dates in calculations.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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. Changing font colour based on a character
    By pjzapped in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-27-2016, 07:02 AM
  2. font colour change based on adjacent cell value
    By nigamnigam in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 06-20-2015, 08:52 PM
  3. Replies: 4
    Last Post: 04-20-2015, 12:29 PM
  4. Replies: 2
    Last Post: 02-22-2015, 11:52 AM
  5. Replies: 3
    Last Post: 06-14-2014, 08:15 PM
  6. Replies: 6
    Last Post: 03-12-2014, 09:52 AM
  7. Use VBA to change font colour of a cell based on its own value (date)
    By grahamc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2012, 03:57 PM

Tags for this Thread

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