Forum Discussion
Seaweedfarm
Sep 28, 2023Copper Contributor
Help with an Excel formula
Hi all, I was wondering if anyone can solve this problem please. I am trying to get a formula that will add something like the following cells: The formula needs to add the numbers depending...
OliverScheurich
Sep 28, 2023Gold Contributor
=SUM(NUMBERVALUE(RIGHT(A1:A3,LEN(A1:A3)-FIND(")",A1:A3))))
You can try this formula. Enter the formula with ctrl+shift+enter if you don't work with Office 365 or Excel for the web or Excel 2021.
- SeaweedfarmOct 02, 2023Copper ContributorHello OliverScheurich. Thank you for your response. I have tried the formula but it does not seem to work.
- HansVogelaarOct 02, 2023MVP
Assuming that the colours have been applied directly, you'll need a custom VBA function:
Function SumByColor(DataRange As Range, ColorCell As Range) As Double Dim Cell As Range Dim Parts() As String Application.Volatile For Each Cell In DataRange If Cell.Interior.Color = ColorCell.Interior.Color Then Parts = Split(Cell.Value) On Error Resume Next SumByColor = SumByColor + Parts(1) On Error GoTo 0 End If Next Cell End Function
Use as in the screenshot:
The attached demo workbook is a macro-enabled workbook, so make sure that you allow macros when you open it.
- SeaweedfarmOct 03, 2023Copper ContributorThank you HansVogelaar. That has worked perfectly!