ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlight column heading of current cell (https://www.excelbanter.com/excel-programming/352357-highlight-column-heading-current-cell.html)

[email protected]

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?


Norman Jones

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



wrote in message
oups.com...
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?




Norman Jones

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" wrote in message
...
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




Don Guillett

Highlight column heading of current cell
 
right click sheet tabview codecopy/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

wrote in message
oups.com...
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?




Norman Jones

Highlight column heading of current cell
 
Hi Don,

I suspect that your interpretation is the correct one!


---
Regards,
Norman



"Don Guillett" wrote in message
...
right click sheet tabview codecopy/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

wrote in message
oups.com...
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?






[email protected]

Highlight column heading of current cell
 
Thanks Don, that did the trick. Just could not find the right syntax.
You're awsome!


Don Guillett

Highlight column heading of current cell
 
Aw shucks, glad to help.

--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Thanks Don, that did the trick. Just could not find the right syntax.
You're awsome!





All times are GMT +1. The time now is 01:38 PM.

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