PDA

View Full Version : Solved: How do you obtain the CellColor value?



EZERYDR
05-19-2011, 07:25 PM
Any ideas on how to retrieve the CellColor value of a range of cells that have been colored manually using Excel then use that value to answer "Y" in another range of cells?

The users will be selecting various cells in a column and highlighting those cells in a particular color (i.e., blue) using the basic color selection tool in Excel. I need the VBA code to read the value of the color in the highlighted cells and use that value to input a "Y" in another cell on the respective row.

For example, If Range("A" & Col).ColorCell = Blue Then Range("D" & Col) = "Y".

Thanks!!

Charlize
05-20-2011, 01:04 AM
'5 is the number of a certain blue
If Range("A" & Col).Interior.ColorIndex = 5 then ...
If you want to know a certain number, tryMsgBox ActiveCell.Interior.ColorIndexCharlize

Kenneth Hobs
05-20-2011, 11:30 AM
Sub ABlueDY()
Dim r As Range
If Selection.Columns.Count > 1 Or Selection.Column <> 1 Then Exit Sub
For Each r In Selection
If r.Interior.ColorIndex = 5 Then
Range("D" & r.Row).Value2 = "Y"
Else
Range("D" & r.Row).Value2 = "N"
End If
Next r
End Sub

EZERYDR
05-20-2011, 06:04 PM
Thanks Charlize....you got me on the right track (again)...finally got the code working as I wanted!!!

Thanks to you also Ken....I'm going to try your solution also.

I'm quickly learning that there are often several options to achieve the desired result with VBA.

Thanks again,
Keith