VBA compare two column values in row range

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Good Day,

I want to create a VBA code that compares two column totals.

Column D and the sum of Columns (AC,AD,AE) within row range of 6 - 36.

Where if these columns are different, (the left column D and the sum of columns AC, AD & AE) an interior color cell of yellow will appear in them until they are of the same value; where next the yellow interior color cell will go away when their values are equal.

For example:
Capturing before .jpg



After the correct entry has been entered &/or they become equal, for example in AE12 if I add the value of 180 the interior colored yellow cells will return back to its original interior cell.

Capturing after .jpg


If you think that Conditional Fomatting might be better, please let me know.

Thank you!
pinaceous
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If you think that Conditional Fomatting might be better
Try:

Dante Amor
ABCDEFGABACADAE
1
5
610120846616540
79332
88440
97116
10914669502029167
11
129548769316750
13
Hoja4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:D36,AC6:AE36Expression=AND($D6<>"",$D6<>SUM($AC6:$AE6))textNO


Note: Applies to: =$D$6:$D$36,$AC$6:$AE$36
 
Upvote 0
Shouldn't need the check that col D is not blank?
Edit: I think that the check that col D is not blank should definitely not be included, otherwise row 11 below would not get highlighted.

23 01 10.xlsm
DEFGABACADAE
610120846616540
79332
88440
97116
10914669502029167
1165
129548769316750
13
CF
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:D36,AC6:AE36Expression=$D6<>SUM($AC6:$AE6)textNO
 
Upvote 0
I think that the check that col D is not blank should definitely not be included, otherwise row 11 below would not get highlighted.
You're right, I don't know why one of my tests, the sum returned 0, so "" <> 0, and it was highlighting the cells, that's why I put the validation.
Thanks Peter.
Peter's formula is correct:
Excel Formula:
=$D6<>SUM($AC6:$AE6)
 
Upvote 0
Hi Guys!

BTW, is there any way I can copy this Conditional Formatting Rule onto other sheets?

For example, in using the Conditional Formatting Rules Manager or by some other means?

The only way that I can think of is to go to each worksheet within the workbook and then creating this rule there.


Please let me know.

Thank you!
pinaceous

Capturdddeddd.PNG
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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