Cell not updating

Lynton

New Member
Joined
Mar 13, 2011
Messages
28
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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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