I would like to be able to have the current cell highlighted in Excel. This
would change based on my cursor position. I think I have seen this before but
I cannot find it now. Thanks for the help.
I would like to be able to have the current cell highlighted in Excel. This
would change based on my cursor position. I think I have seen this before but
I cannot find it now. Thanks for the help.
One way
'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
With .EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With
End Sub
'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in
--
HTH
RP
(remove nothere from the email address if mailing direct)
"D" <D@discussions.microsoft.com> wrote in message
news:2FCC8766-DCFF-4FF2-A194-812BF7718888@microsoft.com...
> I would like to be able to have the current cell highlighted in Excel.
This
> would change based on my cursor position. I think I have seen this before
but
> I cannot find it now. Thanks for the help.
Thanks very much, is there any way to put this into my personal XLS so it is
available all the time for all worksheets?
"Bob Phillips" wrote:
> One way
>
>
> '----------------------------------------------------------------
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> '----------------------------------------------------------------
> Cells.FormatConditions.Delete
> With Target
> With .EntireRow
> .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> With .FormatConditions(1)
> With .Borders(xlTop)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = 5
> End With
> With .Borders(xlBottom)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = 5
> End With
> .Interior.ColorIndex = 20
> End With
> End With
> With .EntireColumn
> .FormatConditions.Delete
> .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> With .FormatConditions(1)
> With .Borders(xlLeft)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = 5
> End With
> With .Borders(xlRight)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = 5
> End With
> .Interior.ColorIndex = 20
> End With
> End With
>
> .FormatConditions.Delete
> .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> .FormatConditions(1).Interior.ColorIndex = 36
> End With
>
> End Sub
>
>
> 'This is worksheet event code, which means that it needs to be
> 'placed in the appropriate worksheet code module, not a standard
> 'code module. To do this, right-click on the sheet tab, select
> 'the View Code option from the menu, and paste the code in
>
> --
>
> HTH
>
> RP
> (remove nothere from the email address if mailing direct)
>
>
> "D" <D@discussions.microsoft.com> wrote in message
> news:2FCC8766-DCFF-4FF2-A194-812BF7718888@microsoft.com...
> > I would like to be able to have the current cell highlighted in Excel.
> This
> > would change based on my cursor position. I think I have seen this before
> but
> > I cannot find it now. Thanks for the help.
>
>
>
Yes, you can put this in Personal.xls. But be aware, it wipes ant
conditional formatting from a sheet.
Option Explicit
Public WithEvents App As Application
'----------------------------------------------------------------
Private Sub App_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
With .EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With
End Sub
Private Sub Workbook_Open()
Set App = Application
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH
RP
(remove nothere from the email address if mailing direct)
"D" <D@discussions.microsoft.com> wrote in message
news:126F1D41-396B-43CC-B0ED-B3D5CC94BA0A@microsoft.com...
> Thanks very much, is there any way to put this into my personal XLS so it
is
> available all the time for all worksheets?
>
>
>
> "Bob Phillips" wrote:
>
> > One way
> >
> >
> > '----------------------------------------------------------------
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > '----------------------------------------------------------------
> > Cells.FormatConditions.Delete
> > With Target
> > With .EntireRow
> > .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> > With .FormatConditions(1)
> > With .Borders(xlTop)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = 5
> > End With
> > With .Borders(xlBottom)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = 5
> > End With
> > .Interior.ColorIndex = 20
> > End With
> > End With
> > With .EntireColumn
> > .FormatConditions.Delete
> > .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> > With .FormatConditions(1)
> > With .Borders(xlLeft)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = 5
> > End With
> > With .Borders(xlRight)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = 5
> > End With
> > .Interior.ColorIndex = 20
> > End With
> > End With
> >
> > .FormatConditions.Delete
> > .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
> > .FormatConditions(1).Interior.ColorIndex = 36
> > End With
> >
> > End Sub
> >
> >
> > 'This is worksheet event code, which means that it needs to be
> > 'placed in the appropriate worksheet code module, not a standard
> > 'code module. To do this, right-click on the sheet tab, select
> > 'the View Code option from the menu, and paste the code in
> >
> > --
> >
> > HTH
> >
> > RP
> > (remove nothere from the email address if mailing direct)
> >
> >
> > "D" <D@discussions.microsoft.com> wrote in message
> > news:2FCC8766-DCFF-4FF2-A194-812BF7718888@microsoft.com...
> > > I would like to be able to have the current cell highlighted in Excel.
> > This
> > > would change based on my cursor position. I think I have seen this
before
> > but
> > > I cannot find it now. Thanks for the help.
> >
> >
> >
Right click on the sheet tab, select view code, and put in code like this:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub
Note that this clears the clipboard and clears the undo stack as I recall,
so you will not be able to paste or undo.
--
Regards,
Tom Ogilvy
"D" <D@discussions.microsoft.com> wrote in message
news:2FCC8766-DCFF-4FF2-A194-812BF7718888@microsoft.com...
> I would like to be able to have the current cell highlighted in Excel.
This
> would change based on my cursor position. I think I have seen this before
but
> I cannot find it now. Thanks for the help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks