Can anyone help me to get the total amount based on the colour of cell? Thanks for advance.
Can anyone help me to get the total amount based on the colour of cell? Thanks for advance.
It's worse idea because if you only change color calculation value doesn't change till F9 or any other events for calculation will be done.
there are many variants and here one of them
Please Login or Register to view this content.
Last edited by BMV; 02-05-2020 at 02:17 AM.
If you can tell us what the criteria is for determining if a cell is to be red we might be able to total from that criteria.
For instance: if the cells are colored red because the values in column B are greater than 1 then this could work.Formula:Please Login or Register to view this content.
Other wise you would require VBA. There are people here who can do that. Unfortunately I am not one of them.
Dave
This sort of thing is unreliable. For example, if you have 1 to 10 in B3:B12, you want to sum cells with red background color, and B5, B7 and B10 have red background color, so the sum would be 16. Using volatile VBA user-defined functions, you could enter a formula like =MyColorSum(B3:B12,"red") and it'd return 16, but if you then change the background color of any of these 3 cells to something else or change the background color of any of the other 7 cells to red, the formula WILL NOT RECALCULATE until you press [F9] (assuming the UDF were volatile) or reenter the formula.
You'd be A LOT BETTER OFF using an extra column to enter, say, X for rows you want to include, then use conditional formatting based on formulas referring to these new entry cells to set the conditional formatting color for the value cells, then use SUMIFS(value_range,new_entry_range,"X") to sum up the selected values. Putting this differently, you're BEGGING FOR PROBLEMS basing any calculations on formatting.
Hi thanks for your suggestion. Can I know why this code can't work in my other file, as I already copy the code into my Visual Basic library of this file? And how to find the number of Color code?
alferd324 .it's example but not code for distribute. For color code I prefer to use additional argument with cell was formatted.
Please Login or Register to view this content.
The string must be changed but I cant check it now
But in the case you use conditional format then you can use sumif(s) with the same conditions.Please Login or Register to view this content.
Yes, i'v checked and DisplayFormat is not available for UDF from worksheet.
If the colour is from a conditional format, I refer you to post 3. it is possible to sum based on the conditional format if we know what it is. Which is why an attachment like suggested in the yellow bar is hugely helpful. your example doesn't contain the conditional formats
Please Login or Register to view this content.
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks