R
rwnelson
I am trying to create a calendar that will automatically color and
shade the cells according to certain conditions. I can't use
Conditional Formatting because if I try to copy and paste items from
the calendar, it copies the manual formatting (which I want to copy) as
well as the conditional formatting (which I do not want).
I created the conditions using VBA which work perfectly but it is
rather lengthy. I currently have 126 individual If/Then functions for
the formatting. I would like to know if there is a way to loop the
conditions so that it can significantly shorten the code. I am new to
the programming world and I was able to figure the following code out
from this news group.
Date = now()
If Range("F7").Value < Date Then Range("F7:G13").Interior.Pattern =
xlGray50 Else Range("F7:G13").Interior.Pattern = xlSolid
If Range("f7").Value >= 1 And Range("F7:G13").Interior.ColorIndex = 15
Then Range("F7:G13").Interior.ColorIndex = 37
If Range("f7").Value = "" Then Range("F7:G13").Interior.ColorIndex = 15
These 3 lines of code are for a single block in the calendar and there
are a total of 42 blocks (7 across x 6 down) with the ranges of
F7:F13, H7:H13, J7:J13, L7:L13, N7:N13, P7:Q13, R7:R13 and then going
down the sheet to F14:F20, H14:H20, and on and on and on to a final
R35:S41.
Any help would be appreciated.
shade the cells according to certain conditions. I can't use
Conditional Formatting because if I try to copy and paste items from
the calendar, it copies the manual formatting (which I want to copy) as
well as the conditional formatting (which I do not want).
I created the conditions using VBA which work perfectly but it is
rather lengthy. I currently have 126 individual If/Then functions for
the formatting. I would like to know if there is a way to loop the
conditions so that it can significantly shorten the code. I am new to
the programming world and I was able to figure the following code out
from this news group.
Date = now()
If Range("F7").Value < Date Then Range("F7:G13").Interior.Pattern =
xlGray50 Else Range("F7:G13").Interior.Pattern = xlSolid
If Range("f7").Value >= 1 And Range("F7:G13").Interior.ColorIndex = 15
Then Range("F7:G13").Interior.ColorIndex = 37
If Range("f7").Value = "" Then Range("F7:G13").Interior.ColorIndex = 15
These 3 lines of code are for a single block in the calendar and there
are a total of 42 blocks (7 across x 6 down) with the ranges of
F7:F13, H7:H13, J7:J13, L7:L13, N7:N13, P7:Q13, R7:R13 and then going
down the sheet to F14:F20, H14:H20, and on and on and on to a final
R35:S41.
Any help would be appreciated.