Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return background color of selected cell

Tags:

excel

vba

I have a spreadsheet which cells in are colored meaningfully.

Does any body know how i can return the background color value of a current cell in Excel sheet?

like image 480
whiz Avatar asked Feb 06 '09 14:02

whiz


People also ask

Can you retrieve the color of one cell in Excel?

Procedure of acquiring cell color (background color) Open Excel in the Excel Application Scope activity. Place a Get Cell Color activity inside the Excel Application Scope activity. 2. Set the properties of the Get Cell Color activity.

Can you use an IF statement to color a cell?

Apply an If-Then rule to all cells by pressing “Ctrl-A” before assigning your rule. If you copy values from colored cells and paste them into new it new cells, the new cells acquire the color of the copied cell.

How do you make a cell background color?

Select the cell or range of cells you want to format. Click Home > Format Cells dialog launcher, or press Ctrl+Shift+F. On the Fill tab, under Background Color, pick the color you want. To use a pattern with two colors, pick a color in the Pattern Color box, and then pick a pattern in the Pattern Style box.


2 Answers

You can use Cell.Interior.Color, I've used it to count the number of cells in a range that have a given background color (ie. matching my legend).

like image 158
Garry Shutler Avatar answered Sep 23 '22 16:09

Garry Shutler


If you are looking at a Table, a Pivot Table, or something with conditional formatting, you can try:

ActiveCell.DisplayFormat.Interior.Color 

This also seems to work just fine on regular cells.

like image 21
RPh_Coder Avatar answered Sep 20 '22 16:09

RPh_Coder