Forum Discussion

squid2023's avatar
squid2023
Copper Contributor
Mar 01, 2024

Custom Function - LET or LAMDA?

I have a custom function to sum based upon interior color of a cell that works.   Can this formula be mimicked by using LET or LAMBDA?   If so.. how?

 

Function ColorSum(myrange As Range, mycolorindex As Integer) As Double
    Dim c As Range
    On Error Resume Next
    For Each c In myrange.Cells
        If c.Interior.ColorIndex = mycolorindex Then _
          ColorSum = ColorSum + c.Value
    Next
End Function
 
 

2 Replies

  • squid2023 

    In addition, any function works with cell value only. If you'd like to work with cell properties like colour, that's VBA or Office Script. 

  • Harun24HR's avatar
    Harun24HR
    Bronze Contributor
    May be not! If those colors are formatted by conditional formatting then it would be possible otherwise VBA is only option.

Resources