Color Cells

B

Beep Beep

What I would like to do is have a macro to do the following. Pick the FC
date and then go to the same date to the right and color & bold that cell
yellow and also color the two cells prior to that also yellow. Example:
Color Yellow Oct 07 - Nov 07 - Dec 07 for FC date

For CS date Jan 08; Feb 08 and Mar 08

Then pick the CS date and to the same except color these cells blue.

I only want to start with dates equal to or greater than January 2008.

FC date CS date Oct-07 Nov-07 Dec-07 Jan-08 Feb-08
19-Dec-07 26-Mar-08 0 0 0 0 0 0
 
J

Joel

MyDate = Range("A2")
'get first day of month

ColCount = 3
Do While Cells(1, ColCount) <> ""
If Month(MyDate) = Month(Cells(1, ColCount)) And _
Year(MyDate) = Year(Cells(1, ColCount)) Then

Exit Do
End If
ColCount = ColCount + 1
Loop

FirstCol = ColCount - 2
If FirstCol < 3 Then
FirstCol = 3
End If
For MyColumns = FirstCol To ColCount
Cells(2, MyColumns).Interior.ColorIndex = 6
Cells(2, MyColumns).Font.Bold = True

Next MyColumns
 
B

Beep Beep

Hi Joel:

A while back you gave me this macro, however it doesn't seem to want to
work. When I try to step into it (F8) it goes no where and no error
messages.
 
J

Joel

did you put the code in a subroutine?

Sub test()

MyDate = Range("A2")
'get first day of month

ColCount = 3
Do While Cells(1, ColCount) <> ""
If Month(MyDate) = Month(Cells(1, ColCount)) And _
Year(MyDate) = Year(Cells(1, ColCount)) Then

Exit Do
End If
ColCount = ColCount + 1
Loop

FirstCol = ColCount - 2
If FirstCol < 3 Then
FirstCol = 3
End If
For MyColumns = FirstCol To ColCount
Cells(2, MyColumns).Interior.ColorIndex = 6
Cells(2, MyColumns).Font.Bold = True

Next MyColumns

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top