Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to discovery the color...

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to discovery the color...

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default How to discovery the color...

ColorIndex is a number, not text. Not sure what you seek, but see
this:
http://www.mvps.org/dmcritchie/excel/colors.htm


Hth,
Merjet

  #4   Report Post  
Posted to microsoft.public.excel.programming
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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to discovery the color...

The problem is that the cell where is the value has more than one value with
different colors.
A1 = "A, B, C"
A = red
B = Blue
C = Black

I put each value in a different cell
C1 = A
D1 = B
E1 = C

But i need to bring also the color each value.

"Lisandro Oliveira" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to discovery the color...

that would be the case if your using conditional formatting to apply the
color.


? xlAutomatic
-4105

For conditional formatting, you would have to check the same conditions you
have defined in the conditional formatting to see which condition is true.
There is no way to directly get the color produced by conditional formatting.

You can look at this, but I think you just need to check the condition which
you should know.
http://www.cpearson.com/excel/CFColors.htm

--
Regards,
Tom Ogilvy



"Lisandro Oliveira" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to discovery the color...

if as you seem to say, a single cell has rich text formatting so parts of the
cell are on color and parts another, then I get this:

? activeCell.Font.ColorIndex
Null

not -4105 with is the value for automatic coloring.

--
Regards,
Tom Ogilvy


"Lisandro Oliveira" wrote:

The problem is that the cell where is the value has more than one value with
different colors.
A1 = "A, B, C"
A = red
B = Blue
C = Black

I put each value in a different cell
C1 = A
D1 = B
E1 = C

But i need to bring also the color each value.

"Lisandro Oliveira" wrote:

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

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
My discovery on DATEDIF and leap year Epinn Excel Worksheet Functions 14 October 17th 06 05:49 AM
My discovery on adding months and days to a date! Epinn Excel Worksheet Functions 8 October 9th 06 10:27 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
CreateNewDocument : an small but interesting discovery from office zhuge Excel Programming 0 May 20th 05 09:41 PM
Great discovery? David Excel Worksheet Functions 0 May 12th 05 08:25 AM


All times are GMT +1. The time now is 02:53 AM.

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

About Us

"It's about Microsoft Excel"