Changing the colour of the cells based on rules using VBA macros

Zafirah_Iqbal

New Member
Joined
Mar 13, 2017
Messages
1
Hi,

I'm new to VBA. I need a VBA macro which can change the colour of the cells based on rules applied.

[TABLE="width: 305"]
<tbody>[TR]
[TD="align: center"]B1[/TD]
[TD="align: center"]B2[/TD]
[TD="align: center"]B3[/TD]
[TD="align: center"]B4[/TD]
[TD="align: center"]B5[/TD]
[/TR]
[TR]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[/TR]
[TR]
[TD]0.01a[/TD]
[TD]0.02a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[/TR]
[TR]
[TD]0.03b[/TD]
[TD]0.01ab[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[TD]0.00a[/TD]
[/TR]
[TR]
[TD]0.06a[/TD]
[TD]0.03a[/TD]
[TD]0.07a[/TD]
[TD]0.04a[/TD]
[TD]0.06a[/TD]
[/TR]
[TR]
[TD]0.15a[/TD]
[TD]0.18ab[/TD]
[TD]0.27b[/TD]
[TD]0.26b[/TD]
[TD]0.22ab[/TD]
[/TR]
</tbody>[/TABLE]

Rules are
  • Any alphabet which is present in criteria column (B1) should not be highlighted in B2,B3 and B4
  • Any alphabet which is greater than the criteria (B1) should be highlighted in Green for B2,B3 and B4 . For eg : A is greater than B
  • Any alphabet which is lesser than the criteria (B1) should be highlighted in Red for in B2,B3 and B4. For eg: A and B are lesser than C

Thanks for your help !!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

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