PDA

View Full Version : Highlight a specfic column when spread sheet opens



BENSON
07-30-2013, 01:29 AM
I have a spreadheet consisting of 7 columns headed Tuesday thru to Monday.The range of each column starts at row 5 end ends at row 240.I would like some code that will highlight a specfic column gray,to match the day of the week.ie: if I open the spreadsheet on a Thursday the range of cells in the column headed Thursday would be highlighted gray

Thks

patel
07-30-2013, 01:48 AM
Private Sub Workbook_Open()
call a
End Sub

Sub a()
LR = Cells(Rows.Count, "A").End(xlUp).Row
Cells.Interior.ColorIndex = 0
sday = Application.WorksheetFunction.Weekday(Date)
Range(Cells(2, sday), Cells(LR, sday)).Interior.ColorIndex = 15
End Sub

BENSON
07-30-2013, 05:11 AM
Private Sub Workbook_Open()
call a
End Sub

Sub a()
LR = Cells(Rows.Count, "A").End(xlUp).Row
Cells.Interior.ColorIndex = 0
sday = Application.WorksheetFunction.Weekday(Date)
Range(Cells(2, sday), Cells(LR, sday)).Interior.ColorIndex = 15
End Sub

BENSON
07-30-2013, 05:13 AM
tried the code but get error message variable not defined where shown


Sub a()
LR = Cells(Rows.Count, "a").End(xlUp).Row
Cells.Interior.ColorIndex = 0
sday = Application.WorksheetFunction.Weekday(Date)
Range(Cells(2, sday), Cells(LR, sday)).Interior.ColorIndex = 15
End Sub

patel
07-30-2013, 11:15 AM
Private Sub Workbook_Open()
call a
End Sub

Sub a()
dim LR as long, sday as integer
LR = Cells(Rows.Count, "A").End(xlUp).Row
Cells.Interior.ColorIndex = 0
sday = Application.WorksheetFunction.Weekday(Date)
Range(Cells(2, sday), Cells(LR, sday)).Interior.ColorIndex = 15
End Sub

BENSON
07-30-2013, 05:58 PM
Private Sub Workbook_Open()
call a
End Sub

Sub a()
dim LR as long, sday as integer
LR = Cells(Rows.Count, "A").End(xlUp).Row
Cells.Interior.ColorIndex = 0
sday = Application.WorksheetFunction.Weekday(Date)
Range(Cells(2, sday), Cells(LR, sday)).Interior.ColorIndex = 15
End Sub