Conditional formatting: a resource hog: VBA alternative?

mskli

New Member
Joined
Feb 20, 2017
Messages
33
Hi:

I have a spreadsheet that looks at live stock data. I have some conditional formatting that is very useful but it can slow down the sheet at volatile times. The question is - can VBA code be used instead of the conditional formatting to achieve better results? (using less cpu resources)

If so - can someone provide sample code that would update the "background fill" after each calculation of data comes in?

I would want to change the background fill in cells b5-b25 using the corresponding value in cells z5:z25. The value in z5 corresponds to the background in b5, z6 to b6 etc etc. There are three possible values in column Z (1,2,3). When 1 - background=white, when 2- background =grey when 3- background =red.


Can someone provide sample code for this so I can test it next week?

thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I can't see such a simple cf rule for such a small range being a drain on your system resources.

You could possibly optimise the cf rules to improve things very slightly under ideal conditions if you have not already done so, but I think that converting this to vba will be a false economy unless you don't want the formatting to be live. i.e. that you will manually run the code to refresh the formatting rather than it happening automatically.
 
Upvote 0
Sorry - I actually have about four hundred of these conditional formats. I would simply apply the code to all of them afterwards. It has to happen in real time. The spreadsheet will calculate about once a second.

I have 64 gb of ram and I'm using a 64 bit excel.
 
Upvote 0
Here is a small screenshot (only about half of the spreadsheet)
1592063525344.png
 
Upvote 0
If you want VBA to run every second applying ~400 different formats to cells, it will almost certainly be worse than CF.
You'd be lucky if it finished the first set of formats, before it had to start again.
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,034
Members
449,061
Latest member
TheRealJoaquin

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