Consulting

Results 1 to 2 of 2

Thread: Highlighting, freezing and scrolling

  1. #1

    Highlighting, freezing and scrolling

    Little bit stumped with this one.

    I have some code that highlights the cell showing today's date.

    The code then freezes at column H. The cell with today's date could be 6 or 7 columns away.

    Does anyone know of code that will scroll to make the column,with the highlighted cell, to the end of the freeze? Also I would like the whole column bordered in red?

    My code is:

    Private Sub Workbook_Open()
    'first make sure the correct
    'sheet is active and ready to be used
    'this sheet must be visible
    ThisWorkbook.Worksheets("Timeline").Visible = xlSheetVisible
    ThisWorkbook.Worksheets("Timeline").Activate
    ActiveSheet.Range("H2").Activate
    ActiveSheet.Cells.Find(What:=Date, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Interior.Color = vbGreen
    Columns("H:H").Select
        ActiveWindow.FreezePanes = True
       End Sub
    Thanks in advance
    Last edited by Aussiebear; 08-08-2013 at 02:56 AM. Reason: Added code tags to supplied code

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    ThisWorkbook.Worksheets("Timeline").Visible = xlSheetVisible
    ThisWorkbook.Worksheets("Timeline").Activate
    ActiveSheet.Range("H2").Activate
    Set AC = ActiveSheet.Cells.Find(What:=Date, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)  '.Activate
    
    With AC
      .Interior.Color = vbGreen
      .EntireColumn.BorderAround xlContinuous, xlThick, , -16776961
      .EntireColumn.Select
      ActiveWindow.FreezePanes = True
      .Select
    End With
    Last edited by p45cal; 08-07-2013 at 08:00 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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