Vba code for comparing same month numbers of 2 consecutive years in separate columns and coloring the latest month cell with var over 15%

ankitgoyal1520

New Member
Joined
Mar 14, 2024
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Suppose
Col 1... col 2.. col 12..col 13..Col 14.. Col..25 Col..26
Jan20..Feb20..dec20..jan21..feb21.. Jan22..Feb..22

The vba code will compare value of jan20 with jan21 and color the cell in jan 21, if variance is greater than 15% and go on comparing jan 21 to Jan22 and color jan 22 column cells
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
From this brief description I would say that it would be easier to use conditional formatting instead of VBA for this. But there is not quite enough information to do either. You describe a variance, but you don't show it in your data layout, or how it is determined. Consider using XL2BB to post your layout, or at least copy the cells and paste as a table.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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