Font

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I write a macro or if-then statement to examine the font colour in a
cell and then return a value dependant on the colour?
 
I,m not sure what you mean by return a value dependant on font colour but
determining the colour is easy enough. The code below returns the colourindex
number of the active cell.

Sub FontColor()
MsgBox "The Font Color Index is " & ActiveCell.Font.ColorIndex
End Sub

Mike
 
This function returns colorindices of the cell given as first argument,
depending on the second argument. If it's TRUE, then returns font colorindex,
if FALSE, returns background colorindex.

Function WhatColor(cella As Range, fontbackgr As Boolean)
Application.Volatile
If fontbackgr Then
WhatColor = cella.Font.ColorIndex
Else
WhatColor = cella.Interior.ColorIndex
End If
End Function

Regards,
Stefi

„sgdav†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top