View Full Version : "obtain the colorindex from another cell"
mahadeshwar
05-18-2006, 03:37 AM
Hi all,
Any ideas how i can obtain the clour index from one cell
so for example
if F1 is red it will print 3 IN G1
thanks
mvidas
05-18-2006, 06:29 AM
You could always use a line of code like: Range("G1").Value = Range("F1").Interior.ColorIndexYou could also use a user-defined function likeFunction GetColorIndex(ByVal TheCell As Range) As Long
GetColorIndex = TheCell.Interior.ColorIndex
End FunctionIn G1 you'd put =GETCOLORINDEX(F1) to have it return 3 for you.
Out of curiosity, any reason for the question title to be in quotes?
Matt
mahadeshwar
05-18-2006, 06:50 AM
sorry that was my fault about the quotes. Your function is wicked but for some dum reason it doesnt work when the cell colours are based on conditional formatting why aggghhh execlll
mvidas
05-18-2006, 06:52 AM
That is true, excel can be funny like that. Take a look at http://www.cpearson.com/excel/CFColors.htm for a way around it, you can use the ColorIndexOfCF function Chip demonstrates there.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.