View Full Version : Solved: Sort by color
ermis1975
01-17-2006, 03:21 PM
I try to make this function works but I cant.
I want to export the color index number and after to sort by color.
Help. Thanks
mdmackillop
01-17-2006, 03:55 PM
Hi,
A UDF need to be in a standard module, not a sheet module. I've tweaked your code slightly as below. Note that Volatile only updated when a calculation is performed on the sheet. Changing colour formats will not show the changed values.
Function CellColorIndex(InRange As Range, Optional OfText As Boolean)
Application.Volatile
If OfText = True Then
CellColorIndex = InRange.Font.ColorIndex
Else
CellColorIndex = InRange.Interior.ColorIndex
End If
End Function
Ken Puls
01-17-2006, 03:57 PM
Hi there,
Move your function to a standard module, and I think you'll find that it works just fine. At least so far as the background colours, anyway. It just won't work in the Worksheet module. :)
HTH,
Ken Puls
01-17-2006, 03:59 PM
Ah! Malcolm you beat me to it!
Good advice, too, btw. Malcolm, do colour changes trigger a worksheet_change event?
Bob Phillips
01-17-2006, 04:05 PM
Ah! Malcolm you beat me to it!
Good advice, too, btw. Malcolm, do colour changes trigger a worksheet_change event?
No!
Ken Puls
01-17-2006, 04:09 PM
No!
:rotlaugh: I thought not, but I figured someone would confirm that for me in a hurry.
ermis1975
01-18-2006, 06:46 AM
ok ! thanks!!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.