ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cell formatting and if statement (https://www.excelbanter.com/excel-discussion-misc-queries/176472-cell-formatting-if-statement.html)

Cortez

Cell formatting and if statement
 
Is there a way to trigger an if statement based on the formatting of a
cell as opposed to the value in the cell?

I have a worksheet that displays channel frequencies in a grid
corresponding to various cities. All locations have each frequency,
but in some cities a given frequency can be in stereo or mono. In the
grid, a location with a frequency in stereo is denoted by a different
colour of text.

I would like to run an if statement from a macro that goes something
like:

if(textcolor(A1)=blue, true, false)

I assume that this isn't possible, but I am not confident enough to
give up on it.

Any help would be appreciated,
Thanks,
TK

mray29

Cell formatting and if statement
 
Have yoiu considered conditional formatting? This automatically formats the
cell based on its contents. Look under Format/Conditional Formatting.

"Cortez" wrote:

Is there a way to trigger an if statement based on the formatting of a
cell as opposed to the value in the cell?

I have a worksheet that displays channel frequencies in a grid
corresponding to various cities. All locations have each frequency,
but in some cities a given frequency can be in stereo or mono. In the
grid, a location with a frequency in stereo is denoted by a different
colour of text.

I would like to run an if statement from a macro that goes something
like:

if(textcolor(A1)=blue, true, false)

I assume that this isn't possible, but I am not confident enough to
give up on it.

Any help would be appreciated,
Thanks,
TK


Cortez

Cell formatting and if statement
 
I am not trying to change the formatting of the cells. I have
multiple cells with the same values, but the existing formatting
differs from cell to cell which denotes a significant variation.

I will reword my example in case it wasn't clear.

here is a sample of what I am looking for, but I don't know if there
is a means of doing it in a macro, or what the syntax would be:

For this example cell A1 contains the value 15 and is in blue text.

if cells(1, 1).TEXTCOLOR = BLUE then cells(1,2).value = "Stereo"

In other words, If the text in cell A1 is blue, then change the text
in B1 to say "stereo".

TK

On Feb 12, 3:06*pm, mray29 wrote:
Have yoiu considered conditional formatting? This automatically formats the
cell based on its contents. Look under Format/Conditional Formatting.



Cortez

Cell formatting and if statement
 
I have figured this out on my own, so I thought I would share it he

If Cells(1, 1).Font.ColorIndex = 5 Then Sheet5.Cells(1, 2).Value =
"stereo"

colorindex 5 is the blue I need, other colors have different
corresponding colorindex values.

This does what I needed, hope someone else finds it helpful.

Thanks,
TK


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com