+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Changing text colour within a strings

Hybrid View

  1. #1
    Registered User
    Join Date
    10-21-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Changing text colour within a strings

    Hi,

    I've attached a copy of the plan - sometimes its easier to see these things in the flesh than try to describe them in words!

    I tried manipulating the code you posted however I could only get it to change the colour of the whole text strings rather than changing bits of it.

    Hope this helps

    Alan
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,535

    Re: Changing text colour within a strings

    Alan, based on your file the below should work (?) - replacing existing Calculate event in full

    Private Sub Worksheet_Calculate()
    Dim lngChar As Long, vData As Variant, rngCell As Range
    On Error GoTo ExitPoint
    Application.EnableEvents = False
    For Each rngCell In Range("H4:H11").Cells
        vData = Application.Transpose(Application.Transpose(rngCell.Offset(, -3).Resize(, 3).Value))
        With rngCell
            .Value = Join(vData, "")
            For lngChar = 1 To Len(.Value)
                .Characters(lngChar, 1).Font.ColorIndex = 1 - (Mid(.Value, lngChar, 1) = "c")
            Next lngChar
        End With
    Next rngCell
    ExitPoint:
    Application.EnableEvents = True
    End Sub
    That said would it not be easier to simply use conditional formatting ?
    ie populate I onwards with c/g based on B:D and format both fill & font accordingly ? This may slow your file a tad but would be simpler.
    Last edited by DonkeyOte; 10-21-2009 at 07:34 AM.

  3. #3
    Registered User
    Join Date
    10-21-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Changing text colour within a strings

    Many thanks for that - it works a treat.

    I have used the conditional formatting method before but sometimes its a bit clunky. You end up typing in a new date in one column and forgetting to update the bar chart side and then all confusion breaks out as to the actual date.

    Thank you

    Alan

+ 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