• 518K Members
• 8,380 Online
• 616K Conversations
SOLVED

New Contributor

If function based on cell color

Hello,

I don't know how to use VBA to do a calculation based on cell color.

My goal is to know which expense is related to which account in order to have the balance of each account separately.

To do so, in the cell E7, I would like to use this formula:

IF(cellC7 is blue ; then E7+D7 ; Else E7=E6).

Is someone able to help me?

2 Replies
Solution

Re: If function based on cell color

@Andre-Vassoigneur hello. Simply put, you can't do this. There is no current function to aggregate by cell color. There are some workarounds though:

3. Table data and filter by color

* This is typically the best way as it gives you data in an adjacent cell which you can write conditions on. For example, with your data, if you inserted a column between C and D, and put either "Personal" or "Company" in D7:D14, you would have a column you could use as a condition in which to aggregate. You could even hide that column afterwards if you didn't want to see it.

Assuming you inserted a column, that would make your current column E now be in F, and your current column F be in G. So the formulas would be:

Column F (Personal account):
=IF(D7="Personal",E7,0)

Column G (Company account):
=IF(D7="Company",E7,0)

Your total balance [column] would stay the same.

Re: If function based on cell color

Thank you @Zack Barresse for your response.

I thought it was impossible too but I would like to be sure.

Have a good day

Related Conversations
Help with an IF AND formula
aanaya6 in Excel on
3 Replies
IF FUNCTION ISN'T WORKING NO MATTER HOW SIMPLE THE COMMAND IS
thomasea in Excel on
6 Replies
not able to type number and text in same cell?
Deleted in Excel on
2 Replies
Which formula to use
Ramon Haagen in Excel on
2 Replies
Automatic coloring sunburst chart
stefan645 in Excel on
2 Replies