Calculation as per color of cell

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello Guys,

I am trying to get the result in sheet2 from sheet 1. If the cells in sheet one is colored, then it should display the amount less by one percent or else the whole amount as shown in the image.
Query for Match and calculate.xlsx
ABCDEFGHIJ
1Sheet 1NameAmountSheet 2NameAmount
2January1,000.00January990.00
3February2,000.00February2,000.00
4March3,000.00March3,000.00
5April4,000.00April3,960.00
6May1,500.00May1,500.00
7June2,500.00June2,500.00
8July3,500.00July3,500.00
9August4,500.00August4,455.00
10September5,500.00September5,445.00
11October6,500.00October6,500.00
12November7,500.00November7,500.00
13December4,500.00December4,500.00
14Sunday1,500.00Sunday1,485.00
15Monday2,500.00Monday2,500.00
16Tuesday3,500.00Tuesday3,500.00
17Wednesday4,500.00Wednesday4,455.00
18Thursday5,500.00Thursday5,500.00
19Friday6,500.00Friday6,500.00
20Saturday7,500.00Saturday7,500.00
Sheet1
Cell Formulas
RangeFormula
I18:J20,I2:I17,J15:J16,J11:J13,J6:J8,J3:J4J3=D3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C:CExpression=MATCH(C1,$M$1:$M$9,0)textNO
 
@RAJESH1960 You can't check a conditional formatted cell color like that.

Replace the current line:

VBA Code:
If 6 = Cells(i, "C").Interior.ColorIndex Then

with the following code:

VBA Code:
If Cells(i, "C").DisplayFormat.Interior.Color = 65535 Then    ' Check for yellow fill

Try that and see if it works as you wanted.
 
Upvote 0
Solution

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
@RAJESH1960 You can't check a conditional formatted cell color like that.

Replace the current line:

VBA Code:
If 6 = Cells(i, "C").Interior.ColorIndex Then

with the following code:

VBA Code:
If Cells(i, "C").DisplayFormat.Interior.Color = 65535 Then    ' Check for yellow fill

Try that and see if it works as you wanted.
Perfect. Thanks JohnnyL. This is what I needed. If it was in the form of formula it would have been much easier to prepare the project. Now have to write the complete code including your code, which is going to be a bit tough for me, as I am not so good at writing codes, for the final result. I will give it a try to write it to get the same perfect result. Thanks once again.
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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