ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Color Cells (https://www.excelbanter.com/excel-programming/408937-color-cells.html)

Beep Beep

Color Cells
 
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


joel

Color Cells
 

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
"Beep Beep" wrote:

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


Beep Beep

Color Cells
 
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.

"Joel" wrote:


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
"Beep Beep" wrote:

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


joel

Color Cells
 
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

"Beep Beep" wrote:

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.

"Joel" wrote:


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
"Beep Beep" wrote:

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



All times are GMT +1. The time now is 12:27 PM.

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