Question: Copy the # 3 Excel template to your Excel file. Use the fill tool to fill the 6 cells ( H 1 through M 1
Copy the # Excel template to your Excel file. Use the fill tool to fill the cells H through M with the
appropriate colors. These colors are under standard colors when you open the fill tool. Create a function
called Colorfunction which takes three parameters see the code below First is the cell location of the color
H through M second is the range of cell locations A:E and finally a TRUE or FALSE condition. True
being the sum, and false the count. Remember the user defined function should be saved in a module in VBA.
Fill in the cells H:M using this function to determine the sum of the values with these colors, and also the
count of the number of cells with the color.
Public Function ColorFunctionrColor As Range, rRange As Range, Optional
SUM As Boolean
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol rColor.Interior.ColorIndex
If SUM True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex lCol Then
vResult WorksheetFunction.SUMrCell vResult
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex lCol Then
vResult vResult
End If
Next rCell
End If
ColorFunction vResult
End Function
Is the output correct? If not, please change the code accordingly to create a correct output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
