Forum Discussion
SarahJP1040
Mar 30, 2023Copper Contributor
Excel - Add value based on colour
Hi All, I have an excel sheet where I am trying to create a cash flow estimate based on a programme of building works. Column C has the planned week number, Column D has the planned duration...
Logaraj Sekar
Mar 30, 2023Steel Contributor
- Open your MS-Excel.
- Press Alt+F11.
- Insert Module from Insert Menu.
- Paste the following code
- Use the formula SUMBYCOLOR in Excel Sheet.
Function SumByColor(SumRange As Range, SumColor As Range)
Dim SumColorValue As Integer
Dim TotalSum As Long
SumColorValue = SumColor.Interior.ColorIndex
Set rCell = SumRange
For Each rCell In SumRange
If rCell.Interior.ColorIndex = SumColorValue Then
TotalSum = TotalSum + rCell.Value
End If
Next rCell
SumByColor = TotalSum
End Function
SarahJP1040
Mar 31, 2023Copper Contributor
Hi Logaraj Sekar , this unfortunately doesn't work either, I don't want to SUM any values based on colour, I just want the sheet to identify a colour has changed due to conditional formatting and then automatically input a value from a column into that coloured cell. Thanks you for your help though 🙂