Consulting

Results 1 to 6 of 6

Thread: Highlight a specfic column when spread sheet opens

  1. #1
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location

    Highlight a specfic column when spread sheet opens

    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

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    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

  3. #3
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    Quote Originally Posted by patel View Post
    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

  4. #4
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    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

  5. #5
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    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

  6. #6
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    Quote Originally Posted by patel View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •