Further Help with Colorfunction and Countif

amyg12

New Member
Joined
Feb 26, 2018
Messages
1
Hello I was wondering if anyone could help I got the below from a post on here quite a while ago which is brilliant it has helped with our spreadsheet but we are having a couple ofissues which I wondered if anyone could possibly help me resolve.

1. We have quite a large amount of data we need touse this on and it seems every time we try to pull the formula down it crashesthe programme any advice.
2. Also we were wondering if there was possibly away to adapt this to pull the information from different tabs I have used thisformula"=SUMPRODUCT(COUNTIF(INDIRECT("'"&$A$4:$A$14&"'!F:F"),B2))"to do a normal countif across the tabs for specific data.
Basically we get leads and there are 132different lead names so that's what the above formula works fine for but thesales rep color code the lead for appropriate, inappropriate, converted and nonconverted so we need to count how many of each lead name are each colour eitherin each tab but preferably across all the tabs.

I hope that makes sense and that you can help before I pull out all of my hair :(


"See if this modification works for you. I added another argument. Your formula would look like this:

=ColorCountifFunction($C$3,"BR",C4:C74,FALSE)

The code has not been tested very much and I don't think a non string value is coded correctly for the second argument so the SUM functionality probably won't work. It should do what you need though.


Code:
Function ColorCountifFunction(rColor As Range, tValue As Variant, 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.
' tValue is a string that would be used in a Countif function
'''''''''''''''''''''''''''''''''''''''

lCol = rColor.Interior.ColorIndex

If SUM = True Then
For Each rCell In rRange
If (rCell.Interior.ColorIndex = lCol) And (rCell.Value = tValue) Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If (rCell.Interior.ColorIndex = lCol) And (rCell.Value = tValue) Then
vResult = 1 + vResult
End If
Next rCell
End If

ColorCountifFunction = vResult
End Function
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top