+ Reply to Thread
Results 1 to 8 of 8

Highlight column heading of current cell

  1. #1

    Highlight column heading of current cell

    I have searched and cannot find an answer. I am using Excel 2000 and
    would like to create a function that will highlight a column heading in
    row three if the current cell is in that particular column. Let's say I
    have 10 columns. If I am at a cell in any row in column 2, then
    highlight cell B2 else leave white. Is this possible via vba? How?


  2. #2
    Norman Jones
    Guest

    Re: Highlight column heading of current cell

    Hi C,

    Try:
    '=============>>
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Range("B3")
    If Target.Column = 2 Then
    .Interior.ColorIndex = 6
    Else
    .Interior.ColorIndex = xlNone
    End If
    End With
    End Sub
    '<<=============
    This is worksheet event code and should be pasted into the worksheets's code
    module (not a standard module and not the workbook's ThisWorkbook module):

    Right-click the worksheet's tab
    Select 'View Code' from the menu and paste the code.
    Alt-F11 to return to Excel.


    ---
    Regards,
    Norman



    <[email protected]> wrote in message
    news:[email protected]...
    >I have searched and cannot find an answer. I am using Excel 2000 and
    > would like to create a function that will highlight a column heading in
    > row three if the current cell is in that particular column. Let's say I
    > have 10 columns. If I am at a cell in any row in column 2, then
    > highlight cell B2 else leave white. Is this possible via vba? How?
    >




  3. #3
    Norman Jones
    Guest

    Re: Highlight column heading of current cell

    Hi C,

    I should add that you indicate the header row to be row 3:

    >> function that will highlight a column heading in row three


    But, later, you say:

    >> If I am at a cell in any row in column 2, then highlight cell B2


    My code assumes the first definition. If, however, the header row is row 2,
    change:

    > With Range("B3")


    to

    > With Range("B2")



    ---
    Regards,
    Norman



    "Norman Jones" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi C,
    >
    > Try:
    > '=============>>
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > With Range("B3")
    > If Target.Column = 2 Then
    > .Interior.ColorIndex = 6
    > Else
    > .Interior.ColorIndex = xlNone
    > End If
    > End With
    > End Sub
    > '<<=============
    > This is worksheet event code and should be pasted into the worksheets's
    > code module (not a standard module and not the workbook's ThisWorkbook
    > module):
    >
    > Right-click the worksheet's tab
    > Select 'View Code' from the menu and paste the code.
    > Alt-F11 to return to Excel.
    >
    >
    > ---
    > Regards,
    > Norman




  4. #4
    Don Guillett
    Guest

    Re: Highlight column heading of current cell

    right click sheet tab>view code>copy/paste this. Be aware that it will erase
    all others.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Cells.Interior.ColorIndex = xlColorIndexNone
    Cells(3, Target.Column).Interior.ColorIndex = 36
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    <[email protected]> wrote in message
    news:[email protected]...
    >I have searched and cannot find an answer. I am using Excel 2000 and
    > would like to create a function that will highlight a column heading in
    > row three if the current cell is in that particular column. Let's say I
    > have 10 columns. If I am at a cell in any row in column 2, then
    > highlight cell B2 else leave white. Is this possible via vba? How?
    >




  5. #5
    Norman Jones
    Guest

    Re: Highlight column heading of current cell

    Hi Don,

    I suspect that your interpretation is the correct one!


    ---
    Regards,
    Norman



    "Don Guillett" <[email protected]> wrote in message
    news:[email protected]...
    > right click sheet tab>view code>copy/paste this. Be aware that it will
    > erase all others.
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Cells.Interior.ColorIndex = xlColorIndexNone
    > Cells(3, Target.Column).Interior.ColorIndex = 36
    > End Sub
    >
    > --
    > Don Guillett
    > SalesAid Software
    > [email protected]
    > <[email protected]> wrote in message
    > news:[email protected]...
    >>I have searched and cannot find an answer. I am using Excel 2000 and
    >> would like to create a function that will highlight a column heading in
    >> row three if the current cell is in that particular column. Let's say I
    >> have 10 columns. If I am at a cell in any row in column 2, then
    >> highlight cell B2 else leave white. Is this possible via vba? How?
    >>

    >
    >




  6. #6

    Re: Highlight column heading of current cell

    Thanks Don, that did the trick. Just could not find the right syntax.
    You're awsome!


  7. #7
    Don Guillett
    Guest

    Re: Highlight column heading of current cell

    Aw shucks, glad to help.

    --
    Don Guillett
    SalesAid Software
    [email protected]
    <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Don, that did the trick. Just could not find the right syntax.
    > You're awsome!
    >




  8. #8
    Jim Thomlinson
    Guest

    Re: Highlight column heading of current cell

    One thing to note with this code (or any similar code that uses the selection
    change event) is that you loose the ability to copy and paste, with no easy
    way around it.
    --
    HTH...

    Jim Thomlinson


    "Norman Jones" wrote:

    > Hi C,
    >
    > Try:
    > '=============>>
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > With Range("B3")
    > If Target.Column = 2 Then
    > .Interior.ColorIndex = 6
    > Else
    > .Interior.ColorIndex = xlNone
    > End If
    > End With
    > End Sub
    > '<<=============
    > This is worksheet event code and should be pasted into the worksheets's code
    > module (not a standard module and not the workbook's ThisWorkbook module):
    >
    > Right-click the worksheet's tab
    > Select 'View Code' from the menu and paste the code.
    > Alt-F11 to return to Excel.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > <[email protected]> wrote in message
    > news:[email protected]...
    > >I have searched and cannot find an answer. I am using Excel 2000 and
    > > would like to create a function that will highlight a column heading in
    > > row three if the current cell is in that particular column. Let's say I
    > > have 10 columns. If I am at a cell in any row in column 2, then
    > > highlight cell B2 else leave white. Is this possible via vba? How?
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1