+ Reply to Thread
Results 1 to 5 of 5

worksheetfunction.text() and font colour

Hybrid View

  1. #1
    Registered User
    Join Date
    08-03-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    19

    worksheetfunction.text() and font colour

    The following code does everything I need it to except for some reason it is not sending the font colour through first or the font colour is getting overwritten. I have formula in other worksheets that are counting the red and the blue to determine which rider in a team it is. For some reason the time sent to "B Grade" worksheet is ending up in black font. Can anyone explain to me why this is occuring.

    I am using worksheet function.text because I am working with elapsed times that could be over 24hrs. I was wondering if the default text colour for the worksheet.text() function is black and if it could be changed.

    Thanks

    Dim Name As Variant
    Dim Start As Date
    Dim ID As String
    Dim RiderCell As Range
    Dim Team As Integer
    Dim RiderSet As Variant
    Dim TagCheck As Variant
    Dim RiderNo As Integer
    Dim RidersRange As Range
    Dim TRow As Integer
    Dim Test As Variant
    
    ElseIf Sheets("Running Sheet").Cells(TRow, 3) >= 200 And Sheets("Running Sheet").Cells(TRow, 3) <= 299 Then
                
                Set RidersRange = Sheets("B Grade").Range("H5:" & Range("H5").End(xlDown).Address)
                'find row number where team number is
                Set RiderCell = RidersRange.Find(Sheets("Running Sheet").Cells(TRow, 3), , xlValues)
                        If RiderNo = 1 Then
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Font.ColorIndex = 3
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).NumberFormat = "[hh]:mm:ss"
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1) = WorksheetFunction.Text(Sheets("Running Sheet").Cells(TRow, 4), "[hh]:mm:ss")
                        'calculates place for this lap
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1) = WorksheetFunction.Max(Sheets("B Grade").Columns(Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Column)) + 1
                        ElseIf RiderNo = 2 Then
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Font.ColorIndex = 5
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).NumberFormat = "[hh]:mm:ss"
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1) = WorksheetFunction.Text(Sheets("Running Sheet").Cells(TRow, 4), "[hh]:mm:ss")
                        Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1) = WorksheetFunction.Max(Sheets("B Grade").Columns(Sheets("B Grade").Cells(RiderCell.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Column)) + 1
                        End If
                    Set RidersRange = Nothing
                    Set RiderCell = Nothing
                    RiderNo = 0
    Last edited by NDBC; 09-05-2009 at 01:23 AM.

  2. #2
    Registered User
    Join Date
    08-03-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    19

    Re: worksheetfunction.text() and font colour

    Deleted second post because it was wrong.
    Last edited by NDBC; 09-05-2009 at 12:50 AM.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: worksheetfunction.text() and font colour

    Hello NDBC,

    Is this by chance related to your post here?

    If so, you need to include a link to this post. Others will then know what progress has been here and elsewhere. It will avoid duplication of effort and wasting the time of the those helping you.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    08-03-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    19

    Re: worksheetfunction.text() and font colour

    Lieth,

    Yes it is exactly the same post, but in a different forum. The race is on tomorrow so I need to maximise my chances of getting this done. As I did last time I posted I will either put up the results in both forums or at the very least say I solved it and post the link.

    Anyway I was just coming back to appologise for wasting your time. The error was only happenning at what seemed like random times which was very confusing. I have now tracked it down to worksheets being protected and the code not unprotecting it until part the way through the process.

    Thanks for looking though.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: worksheetfunction.text() and font colour

    Hello NDBC,

    Good job on figuring that out. By the way, you weren't wasting my time. Microsoft.Excel.Public doesn't care about cross posting, but most other sites appreciate a heads up so everyone is on the same page. I'll marked this solved for you.

+ 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