Stop searching. Start learning and developing your excel skills.
Macro
VBA
Formula
Function
Shortcut
Tricks

» » VBA To Define UDF To Sum By Color

VBA To Define UDF To Sum By Color

June 02, 2017 |
This is also related to below queries:
  1. sum by color excel
  2. sum by color vba
  3. excel formula to sum colored cells
  4. colorfunction excel
The Codes:
Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
  If cl.Interior.ColorIndex = ColIndex Then
    cSum = WorksheetFunction.SUM(cl, cSum)
  End If
Next cl
SumByColor = cSum
End Function
Steps:
  1. Copy and paste the code in your personal.XLSB modules
  2. In your spreadsheet, in any cells that you want to insert SumByColor formula, call above Function by using 'Insert Function' then select 'User Defined' category
  3. Select a function: PERSONAL.XLSB!SumByColor
    • Select Color cell
    • Select Range to SUM


No comments:

Post a Comment