Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Determining Target font colour

You can do this a few ways depending on what you prefer.

1.) Put this code in Worksheet Module or the worksheet you wish to test. I
think this may get a bit annoying but it will do the trick.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Target.Font.ColorIndex
Case Is = 1
MsgBox "The Font ColorIndex = 1 or Black"
Case Is = 6
MsgBox "The Font ColorIndex = 6 or Yellow"
End Select

End Sub

2.) You can call a user defined function from a cell, which will return
Black or Yellow.

Public Function DetectFontColor(CellToDetect As Range) As String

Select Case CellToDetect.Font.ColorIndex
Case Is = 1
DetectFontColor = "Black"
Case Is = 6
DetectFontColor = "Yellow"
End Select

End Function

3.) You could use the immediate window in the VB Editor. Just select a cell,
then in VBE select ViewImmediate Window then type this:

?ActiveCell.Font.ColorIndex

This will give you the colorindex number.

I hope one of these helped! If so, please let me know and click "YES" below.
--
Cheers,
Ryan


"kirkm" wrote:


I'm wanting to detect if the font colour in the selected cell is black
or yellow.
Been playing with target. and the drop down items but can't see
anything (yet).

Any help appreciated.
Thanks - Kirk

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
different colour font in same cel ILMER57 Excel Worksheet Functions 4 April 12th 10 04:57 PM
textBox font colour the same as cell font colour???????? Sophie Excel Discussion (Misc queries) 4 February 13th 09 10:15 AM
Using Font Colour Kevin Excel Programming 2 September 3rd 06 06:19 PM
can the fill colour of a bar be tied to the data font colour data PaulC Charts and Charting in Excel 0 June 23rd 06 01:21 AM
need a formula for setting colour target cells dave6453 Excel Worksheet Functions 1 January 18th 06 11:22 AM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"