Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Extracting Highlight Color of Cell

Status
Not open for further replies.

DummyForAccess

Technical User
Aug 7, 2002
38
US
Hi, I'm wondering if there's any way possible to extract the highlight color from a given cell as a value? If I can create a column on a spreadsheet, have it extract the color value of an adjacent cell, I could then be able to filter by color....
 
Here's a routine I just wrote for you...

Activate this in the cell to the right of the top cell in your column. It will do as you require - place the color index number opposite each cell in the column to the left - as far down as there is data in the column.

Sub Generate_ColorNumbers()
Application.ScreenUpdating = False
Set_Range
For Each c In Range("color_cells")
ActiveCell.Value = ActiveCell.Offset(0, -1) _
.Interior.ColorIndex
ActiveCell.Offset(1, 0).Activate
Next
Application.ScreenUpdating = True
End Sub

Sub Set_Range()
topcell = ActiveCell.Offset(0, -1).Address
colm = ActiveCell.Offset(0, -1).Column
botmcell = Cells(65536, colm).End(xlUp).Address
rng = topcell & ":" & botmcell
Range(rng).Name = "color_cells"
End Sub


I hope this is what you required. Please advise as to how it fits.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Or as a function:

Function ColInd(Rng as range)
application.volatile
ColInd = rng.interior.colorindex
end function
Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
DFA,

I'm doing a "follow-up" on your posting to see how you made out.

Can you please provide an update as to how you made out. If you need further help, please advise. Thanks. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top