S
SteveK
Hey everyone,
Ok this is going to be a detailed description so if it is a little
confusing so bare with me. My macro experience is nothing more than beginner
also so any sort of help will be much appreciated. What I have is a building
entry pass list of about 250 people and 5 different categories that people
are defined with.
What I need is a macro that will count the number of cells, that have a
specific background color and display the results in a single cell below the
range. I.E. One of the categories is "Need Deleted" and has a red background
color. There are 5 different colors and 6 different columns. Each column of
names has a spacer column between it (This is where some of my problems
arise). The way the spread sheet is setup, the results are in a range of
there own with the specific amount for each color displays for the
corresponding column. As of right now i have a COLORFUNCTION equation in
there that counts them but it doesn't automatically update the result when
you change the color. (EX. =ColorFunction(D57,E5:E54,FALSE)).
A guy I work with found this macro but I can't seem to get it working
because, well I just don't have that much experience with macros (It is a
general macro and nothing is defined specifically yet.):
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As
Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
''''''''''''''''''''''''''''''''''''''
'Written by Ozgrid Business Applications
'www.ozgrid.com
'Sums or counts cells based on a specified fill color.
'''''''''''''''''''''''''''''''''''''''
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
I took one look at that and got confused about all the ranges and such. I
am wondering if anyone has any ideas on if i can use this macro or if there
is a better route to the solution, or if I am just using the colorfunction
wrong and it is on my end that it is not automatically updating when i change
the color. Thanks a lot in advance for any help received.
Cheers,
Steve
Ok this is going to be a detailed description so if it is a little
confusing so bare with me. My macro experience is nothing more than beginner
also so any sort of help will be much appreciated. What I have is a building
entry pass list of about 250 people and 5 different categories that people
are defined with.
What I need is a macro that will count the number of cells, that have a
specific background color and display the results in a single cell below the
range. I.E. One of the categories is "Need Deleted" and has a red background
color. There are 5 different colors and 6 different columns. Each column of
names has a spacer column between it (This is where some of my problems
arise). The way the spread sheet is setup, the results are in a range of
there own with the specific amount for each color displays for the
corresponding column. As of right now i have a COLORFUNCTION equation in
there that counts them but it doesn't automatically update the result when
you change the color. (EX. =ColorFunction(D57,E5:E54,FALSE)).
A guy I work with found this macro but I can't seem to get it working
because, well I just don't have that much experience with macros (It is a
general macro and nothing is defined specifically yet.):
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As
Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
''''''''''''''''''''''''''''''''''''''
'Written by Ozgrid Business Applications
'www.ozgrid.com
'Sums or counts cells based on a specified fill color.
'''''''''''''''''''''''''''''''''''''''
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
I took one look at that and got confused about all the ranges and such. I
am wondering if anyone has any ideas on if i can use this macro or if there
is a better route to the solution, or if I am just using the colorfunction
wrong and it is on my end that it is not automatically updating when i change
the color. Thanks a lot in advance for any help received.
Cheers,
Steve