chengmans123
New Member
- Joined
- Jul 7, 2020
- Messages
- 1
- Office Version
- 365
Hi Everyone,
I've found codes online to help me Sumifs by colour for situations where the column with coloured data is to be summed.
However, i'm looking Sumifs by multiple criteria across different columns. See example below.
I have the following code to countifs by colour and price points
If Price Point = Purple, Price Point = $7.99 then count the number of weeks on $7.99
I want to create a function where it does something similar but instead of counting it sums up the column "Unit Sales"
ie. If Price Point = Purple, Price Point = $7.99, then sum the column "Unit Sales"
A function that will give me the number "527 Units" in the picture above.
Thank you for taking the time to read this post!
I've found codes online to help me Sumifs by colour for situations where the column with coloured data is to be summed.
However, i'm looking Sumifs by multiple criteria across different columns. See example below.
I have the following code to countifs by colour and price points
If Price Point = Purple, Price Point = $7.99 then count the number of weeks on $7.99
VBA Code:
Function COUNTIFCOLOUR(Colour As Range, UnitPrice As Range, rng As Range) As Long
Dim NoCells As Long
Dim cellColour As Long
Dim rngCell As Range
cellColour = Colour.Interior.Color
For Each rngCell In rng
If rngCell.Interior.Color = cellColour And rngCell.Value = UnitPrice Then
NoCells = NoCells + 1
End If
Next
COUNTIFCOLOUR = NoCells
End Function
I want to create a function where it does something similar but instead of counting it sums up the column "Unit Sales"
ie. If Price Point = Purple, Price Point = $7.99, then sum the column "Unit Sales"
A function that will give me the number "527 Units" in the picture above.
Thank you for taking the time to read this post!