Cell("Color",ref) Excel formula

cchristy

New Member
Joined
Feb 24, 2011
Messages
13
Hi all,

I am trying to find the color of a cell or set the color and came across the "cell(type, Ref)" formula. I cant seem to find much info as to what this does though.

One of the types listed is color, so cell("color",k5) would return the color of k5.

I dont want to use VBA but would just like to know what this function does.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Check out the helpfile:

<TABLE class=collapse><TBODY><TR class=trbgeven><TH class=thhead vAlign=top align=left>info_type</TH><TH class=thhead vAlign=top align=left>Returns</TH></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"address"</TD><TD class=noborder vAlign=top align=left>Reference of the first cell in reference, as text.</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"col"</TD><TD class=noborder vAlign=top align=left>Column number of the cell in reference.</TD></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"color"</TD><TD class=noborder vAlign=top align=left>The value 1 if the cell is formatted in color for negative values; otherwise returns 0 (zero).</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"contents"</TD><TD class=noborder vAlign=top align=left>Value of the upper-left cell in reference; not a formula.</TD></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"filename"</TD><TD class=noborder vAlign=top align=left>Filename (including full path) of the file that contains reference, as text. Returns empty text ("") if the worksheet that contains reference has not yet been saved.</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"format"</TD><TD class=noborder vAlign=top align=left>Text value corresponding to the number format of the cell. The text values for the various formats are shown in the following table. Returns "-" at the end of the text value if the cell is formatted in color for negative values. Returns "()" at the end of the text value if the cell is formatted with parentheses for positive or all values.</TD></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"parentheses"</TD><TD class=noborder vAlign=top align=left>The value 1 if the cell is formatted with parentheses for positive or all values; otherwise returns 0.</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"prefix"</TD><TD class=noborder vAlign=top align=left>Text value corresponding to the "label prefix" of the cell. Returns single quotation mark (') if the cell contains left-aligned text, double quotation mark (") if the cell contains right-aligned text, caret (^) if the cell contains centered text, backslash (\) if the cell contains fill-aligned text, and empty text ("") if the cell contains anything else.</TD></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"protect"</TD><TD class=noborder vAlign=top align=left>The value 0 if the cell is not locked; otherwise returns 1 if the cell is locked.</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"row"</TD><TD class=noborder vAlign=top align=left>Row number of the cell in reference.</TD></TR><TR class=trbgodd><TD class=noborder vAlign=top align=left>"type"</TD><TD class=noborder vAlign=top align=left>Text value corresponding to the type of data in the cell. Returns "b" for blank if the cell is empty, "l" for label if the cell contains a text constant, and "v" for value if the cell contains anything else.</TD></TR><TR class=trbgeven><TD class=noborder vAlign=top align=left>"width"</TD><TD class=noborder vAlign=top align=left>Column width of the cell, rounded off to an integer. Each unit of column width is equal to the width of one character in the default font size.</TD></TR></TBODY></TABLE>

So =Cell("color",A1) would return a 1 if the value is formatted as [Red] (0.00), and a 0 if it had no color formatting. Note that this has to do with the Number Format, not the cell color.

See Chip Pearson's site for how to deal with cell colors: http://www.cpearson.com/excel/Colors.aspx

HTH,
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,245
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top