View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Lisandro Oliveira Lisandro Oliveira is offline
external usenet poster
 
Posts: 6
Default How to discovery the color...

Hi Tom,

The fixed color that is returning is "-4105"
Doesnt matter if it is blue or red, always return "-4105" from
r.Font.ColorIndex

Why??

This is the code:

For i = 0 To UBound(meuarray)
Range("A2").ClearFormats
Range("A2").Value = meuarray(i)
Set test = Range("A2")
If test.Font.ColorIndex = "3" Then
Cells(ll, col + 1).Select
Selection.Font.ColorIndex = 3
End If
Cells(ll, col + 1).Value = meuarray(i)
ll = ll + 1
Next




"Tom Ogilvy" wrote:

for the Font:
Dim r as Range
set r = range(€œA1€)

If r.Font.ColorIndex = 3 then
Msgbox €œred€
End if

if the cell background is red:

Dim r as Range
set r = range(€œA1€)

If r.Interior.ColorIndex = 3 then
Msgbox €œred€
End if

--
regards,
Tom Ogilvy

"Lisandro Oliveira" wrote:

How can I know what is the color of the value of variable?
Example:

Cell A1 = €œtest€ (its in red)

VBA:

Dim var as string
Var = range(€œA1€).value

If var.Interior.ColorIndex = red then
Msgbox €œred€
End if

Tks,
Lisandro