Cell not updating

Lynton

New Member
Joined
Mar 13, 2011
Messages
21
I have a spreadsheet containing numerous Formulas that all work perfectly.
Basically its an invoice system that records invoices as they are created.
The invoice record sheet creates the invoices in cells with a yellow background colour.
When the invoice is paid the cell background colour is changed to "no fil".
I want to sum the total amounts in one column of only the Yellow cells.

I have created a Function:
--------------------------------------------------------------------
Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Double
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
___________________________________________________________________
On the worksheet I have entered =SumByColor(D2,E6:E2000)
Where D2 is always yellow and E6:E2000 are the cells I need "summed" if they are yellow.
This all works well.
But it doesn't update if I add another invoice to the list ?
If I delete the cell containing SumByColor(D2,E6:E2000) and then press ctrl z (undo) it calculates correctly.
all other formulas work correctly and update as required.
any help appreciated.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try adding the following code to the bigging line of your UDF.
Just under Function SumByColor(CellColor As Range, rRange As Range) is OK.

VBA Code:
application.volatile

This method marks a user-defined function as volatile. A volatile function must be recalculated whenever calculation occurs in any cells on the worksheet.
 
Upvote 0
How are the cells colored? Conditional Formatting?
If so, you need to use "DisplayFormat.Interior.Color"
 
Upvote 0
Try adding the following code to the bigging line of your UDF.
Just under Function SumByColor(CellColor As Range, rRange As Range) is OK.

VBA Code:
application.volatile

This method marks a user-defined function as volatile. A volatile function must be recalculated whenever calculation occurs in any cells on the worksheet.
Many thanks iv done that but it still doesn't update.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top