VBA - Highlight Value That Doesnt Match Top Value

vba_monkey

Board Regular
Joined
Dec 18, 2013
Messages
112
Please let me know if this doesnt make sense.

This is a simplified version of a table of insurance policies that I have and I need to go through the values in the third column and highlight commision rates that differ from the first value of each policy.

For example, any endorsement for policy P1 that has a commission rate that isnt 90% should be highlighted in red.

Policy No.Endorsement No.Commission Share
P1E190%
E286%
E390%
E490%
E590%
P2E195%
E290%
E395%
P3E185%
E285%
E380%
E485%

<colgroup><col><col><col></colgroup><tbody>
</tbody>


Values in this table that should show as red are P1,E2 (86%), P2,E2(90%) and P3,E3 (80%).

Any help will be greatly appreciated. Thanks.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Am no VBA expert but this works

Code:
Sub HighLiteNotTop()
Application.ScreenUpdating = False
Lastrow = Worksheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
lastpol = ""
For i = 2 To Lastrow
If Worksheets("Sheet1").Cells(i, 1) <> "" Then currpol = Cells(i, 1): lastpol = currpol: share = Cells(i, 3) Else
If Worksheets("Sheet1").Cells(i, 3) <> share Then Cells(i, 3).Interior.ColorIndex = 3

Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

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