Forum Discussion
Celia9
Oct 05, 2022Copper Contributor
Macro for conditional format (to avoid slowing down file)
Hi all,
I have a conditional format like this (also in attached file). It works great, but my file gets really slow because of it.
Can I transfer this into a macro, so I can just press a button once a week, the new conditional format gets pulled and stored?
HansVogelaar Could you help me with this?
5 Replies
Sort By
Do you mean that you want to highlight the holidays by direct formatting instead of conditional formatting?
- Celia9Copper ContributorYes, I think I do. But it still should be based on the data like the conditional format is setup.
Try this:
Sub HighlightHolidays() Dim hol As Variant Dim emp As String Dim dtm As Date Dim i As Long Dim r As Long Dim c As Long Application.ScreenUpdating = False hol = Range("TableHolidays").Value For i = 1 To UBound(hol) dtm = hol(i, 2) r = Range("A:A").Find(What:=dtm, LookAt:=xlWhole).Row emp = hol(i, 1) c = Range("1:1").Find(What:=emp, LookAt:=xlWhole).Column Cells(r, c).Interior.Color = RGB(217, 217, 217) Next i Application.ScreenUpdating = True End Sub