Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is a UDF I setup to count the number of cells with a matching colorindex
value to the second parameter. syntax CountColor(Range of Cell,Colorindex value) ex CountColor(A1:B32,14) Public Function CountColor(R As Range, C As Integer) Dim cell As Range, Count As Integer Count = 0 For Each cell In R If cell.Interior.ColorIndex = C Then Count = Count + 1 End If Next cell CountColor = Count End Function I also use this one as an easy way to get the current interior colorindex value. Public Function GetColor(R As Range) GetColor = R.Interior.ColorIndex End Function HTH Cal " wrote: Hi, This is my first post. I have a simple VBA function that counts the number of colored cells (of a certain color), and prints in to the cell which activates the function. It works fine but i want change the function så that will become more 'general', meaning that i'll be able to use it from meny other cells. I want to know if there is any way to sent somthing like functionName(currentCellRowNumber) insted of functionName(36) like i do now where i have to change the number manually every time. I'll appreciate any help i can get. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Current year and current week number | Excel Discussion (Misc queries) | |||
How to count a range of number to a given parameter or criteria. | Excel Worksheet Functions | |||
How do you return current ROW number to definition in NAME function? | Setting up and Configuration of Excel | |||
Sending a parameter to a Userform | Excel Programming | |||
Format when sending a range as parameter to a custom function | Excel Programming |