ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Curser Highlight (https://www.excelbanter.com/excel-discussion-misc-queries/153918-curser-highlight.html)

JayBham62

Curser Highlight
 
Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?

Dave Peterson

Curser Highlight
 
You may want to try Chip Pearson's Rowliner:
http://www.cpearson.com/excel/RowLiner.htm

JayBham62 wrote:

Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?


--

Dave Peterson

Jim May

Curser Highlight
 
Paste this into the files Thisworkbook Module - Selected cell will be
highlighted
in all your sheets - even better this macro does not affect existing
Conditional formatting..



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Static OldCell As Range
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End Sub

"JayBham62" wrote:

Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?


JayBham62

Curser Highlight
 


"Jim May" wrote:

Paste this into the files Thisworkbook Module - Selected cell will be
highlighted
in all your sheets - even better this macro does not affect existing
Conditional formatting..



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Static OldCell As Range
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End Sub

"JayBham62" wrote:

Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?


JayBham62

Curser Highlight
 
Thanks Jim That is cool!

"Jim May" wrote:

Paste this into the files Thisworkbook Module - Selected cell will be
highlighted
in all your sheets - even better this macro does not affect existing
Conditional formatting..



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Static OldCell As Range
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End Sub

"JayBham62" wrote:

Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?


Jim May

Curser Highlight
 
Thanks for the feedback; glad it worked for you...

"JayBham62" wrote:

Thanks Jim That is cool!

"Jim May" wrote:

Paste this into the files Thisworkbook Module - Selected cell will be
highlighted
in all your sheets - even better this macro does not affect existing
Conditional formatting..



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Static OldCell As Range
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End Sub

"JayBham62" wrote:

Does anyone know how to make the cell highlight, only when it it selected,
and keep moving with the curser as you move around the spreadsheet?


Max

Curser Highlight
 
Nice sub there, Jim.

Is there a way for a user choice to toggle the feature on/off, when the wb
is opened?

Eg: when I'm working on the wb, I may want it to be toggled off so that undo
is not disabled (as per normal). But when I'm presenting/discussing the wb
with others, I wld like to have the cell highlight feature "on".

Thanks
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---



Jim May

Curser Highlight
 
Thanks Max;
My initial response goes to perhaps setting up a Flag (boolean) type for
On/Off, True/False... you know...

"Max" wrote:

Nice sub there, Jim.

Is there a way for a user choice to toggle the feature on/off, when the wb
is opened?

Eg: when I'm working on the wb, I may want it to be toggled off so that undo
is not disabled (as per normal). But when I'm presenting/discussing the wb
with others, I wld like to have the cell highlight feature "on".

Thanks
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---




Max

Curser Highlight
 
"Jim May" wrote
Thanks Max;
My initial response goes to perhaps setting up a Flag (boolean) type for
On/Off, True/False... you know


I won't know how to do that <g.
Any sample code how it could be worked into here?
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
....



Jim May

Curser Highlight
 
Here's my entire code:
1) Paste these top two (2) macros into your ThisWorkbook Module.
2) Paste the next Block (one Declaration ststement & one Macro into a
Standard module)
3) Use the Forms Command Button and assign the TogglebFlag macro to it.

Hope that helps..
Jim

Private Sub Workbook_Open()
bFlag = True
ActiveCell.Interior.ColorIndex = xlColorIndexNone
ActiveCell.Borders.LineStyle = xlLineStyleNone
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Static OldCell As Range
If bFlag = True Then
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End If
End Sub

2:

Public bFlag As Boolean ' This should appear in the Declarations Section

Sub TogglebFlag()
Set OldCell = Nothing
ActiveCell.Interior.ColorIndex = xlColorIndexNone
ActiveCell.Borders.LineStyle = xlLineStyleNone
If bFlag = True Then
bFlag = False
Else: bFlag = True
End If
End Sub





"Max" wrote:

"Jim May" wrote
Thanks Max;
My initial response goes to perhaps setting up a Flag (boolean) type for
On/Off, True/False... you know


I won't know how to do that <g.
Any sample code how it could be worked into here?
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
....




Max

Curser Highlight
 
Brilliant, Jim !
Many thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---




All times are GMT +1. The time now is 11:28 AM.

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