0% found this document useful (0 votes)
23 views1 page

VBA Function to Sum by Color

This VBA function takes in two ranges as arguments, one containing the color to sum and another containing the cells to sum. It loops through the second range, checks if each cell's interior color matches the first range's color, and if so, sums the cell's value to a running total variable. The final total is returned.

Uploaded by

Andreea Olteanu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

VBA Function to Sum by Color

This VBA function takes in two ranges as arguments, one containing the color to sum and another containing the cells to sum. It loops through the second range, checks if each cell's interior color matches the first range's color, and if so, sums the cell's value to a running total variable. The final total is returned.

Uploaded by

Andreea Olteanu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Alt+F11 Insert-Module : Function SumColor(rColor As Range, rSumRange As Range) 'Written by Ozgrid Business Applications '[Link].

.com Dim rCell As Range Dim iCol As Integer Dim vResult iCol = [Link] For Each rCell In rSumRange If [Link] = iCol Then vResult = [Link](rCell) + vResult End If Next rCell SumColor = vResult End Function Alt+Q - Save

You might also like