ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formatting (https://www.excelbanter.com/excel-programming/336472-conditional-formatting.html)

Andibevan[_4_]

Conditional Formatting
 
I have a large spreadsheet that is a calender of resources and their
availability. The weekends are all greyed out and I have all the weekdays
formatted using the same conditional formatting.

Is there any way to create a "style" so that I can easily change the
formatting that is applied under each condition.

(i.e. I don't want to change the conditions, I want to change the
formatting)



K Dales[_2_]

Conditional Formatting
 
I can think of 2 ways to go about this; one easier to code and the other is
the more "elegant" solution:
1) Write a sub that steps through the cells in your range and modifies the
FormatCondition; basic outline as follows (this assumes the initial format
condition is already set in all the cells in the range):
Sub MyFormat(FormatRange as Range, InteriorColor as Long, ...)
' You can add as many parameters as you would like in order to define your
format
Dim FormatCell as Range
For Each FormatCell in FormatRange
With FormatCell.FormatConditions(1)
.Interior.Color = InteriorColor
... ' can adjust other properties here using similar statements and
parameter values
Next FormatCell
End Sub

A better (more flexible and 'stronger') way to do this would be to create a
custom class that would mimic a "style" by taking a FormatCondition object
and adding your own properties and methods to allow you to treat it just like
a format style. But the coding for that is too complex for me to get into
here and unless you want to pursue this I think the above method would work
best for your current issue.

HTH!
--
- K Dales


"Andibevan" wrote:

I have a large spreadsheet that is a calender of resources and their
availability. The weekends are all greyed out and I have all the weekdays
formatted using the same conditional formatting.

Is there any way to create a "style" so that I can easily change the
formatting that is applied under each condition.

(i.e. I don't want to change the conditions, I want to change the
formatting)




Andibevan[_4_]

Conditional Formatting
 
Thanks for the advice - I think the simpler option is the only one worth
persuing due to time.

Thanks

"K Dales" wrote in message
...
I can think of 2 ways to go about this; one easier to code and the other

is
the more "elegant" solution:
1) Write a sub that steps through the cells in your range and modifies the
FormatCondition; basic outline as follows (this assumes the initial format
condition is already set in all the cells in the range):
Sub MyFormat(FormatRange as Range, InteriorColor as Long, ...)
' You can add as many parameters as you would like in order to define your
format
Dim FormatCell as Range
For Each FormatCell in FormatRange
With FormatCell.FormatConditions(1)
.Interior.Color = InteriorColor
... ' can adjust other properties here using similar statements and
parameter values
Next FormatCell
End Sub

A better (more flexible and 'stronger') way to do this would be to create

a
custom class that would mimic a "style" by taking a FormatCondition object
and adding your own properties and methods to allow you to treat it just

like
a format style. But the coding for that is too complex for me to get into
here and unless you want to pursue this I think the above method would

work
best for your current issue.

HTH!
--
- K Dales


"Andibevan" wrote:

I have a large spreadsheet that is a calender of resources and their
availability. The weekends are all greyed out and I have all the

weekdays
formatted using the same conditional formatting.

Is there any way to create a "style" so that I can easily change the
formatting that is applied under each condition.

(i.e. I don't want to change the conditions, I want to change the
formatting)







All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com