Conditional colour to normal colour
- 0 0
-
shares
Have you ever wanted to 'set' the colours / fonts etc from conditional formatting ?
If so, the below script should help with turning a selection from dynamic to fixed colours.
The below example - we can set a basic colour scale on a range :
On the home menu > Conditional Formatting > Colour Scales :
You should end up with something like this :
If you change any of the numbers - the colours will adjust responsively :
If you DON'T want the colours changing , as yet, there's no option in Excel to copy/paste or fix the colours to actual background colours.
For example, below I've added a blue background behind the conditional format, and copied/pasted the column formats. Only the blue is copied.
Use the following code in a new module -
This will work when triggered on any selection. There's a limit of 500k on the amount of cells it'll work on, as it is iterative ( colour scales particularly need to be processed as individual elements due to the diverging colours) .
This subroutine can be called from other subroutines, say if you had a process to copy/paste data and conditional formats between sheets / ranges , and fix once you've posted.
So for example - if you wanted to colour a set of numbers / dates etc. just run the stored procedure, and you can copy / paste formats.
Selection has already had procedure run :
Colour gradient generated by conditional formatting can now be applied to a new range.
Nice!