ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing active cell to a color (https://www.excelbanter.com/excel-programming/317470-changing-active-cell-color.html)

Bob Reynolds[_3_]

Changing active cell to a color
 
I have a need to have the active cell in my worksheet to be a highlighted
color for easy recognition. Is there a way to program whatever cell is
active to change to highlighted color and have the highlight move from cell
to cell.
thanks in advance
Bob Reynolds



Don Guillett[_4_]

Changing active cell to a color
 
This works well. Right click on sheet tabview codeinsert thisSAVE.
As written, does the entire row. Just change
Set MyRng = Target.EntireRow
to
Set MyRng = Target
for only one cell


'McCurdy.Here is something inspired by Don Guillett.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRng As Range
Set MyRng = Target.EntireRow
Application.EnableEvents = False
On Error GoTo end1
Application.Cells.FormatConditions.Delete
With MyRng
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ROW()=ROW(INDIRECT(CELL(""address"")))"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
.FormatConditions(1).Interior.ColorIndex = 36
End With
end1:
Application.EnableEvents = True
End Sub


--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in message
. ..
I have a need to have the active cell in my worksheet to be a highlighted
color for easy recognition. Is there a way to program whatever cell is
active to change to highlighted color and have the highlight move from

cell
to cell.
thanks in advance
Bob Reynolds





pegbol

Changing active cell to a color
 

Hi,

Greetings from La Paz, Bolivia.

Paste the next code in the VB Excel editor.


Option Explicit

Private Sub Worksheet_Calculate()
Resalta
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Resalta
End Sub

Private Sub Resalta()
Dim R As Long
Dim C As Long
Dim X As String
R = ActiveCell.Row
C = ActiveCell.Column

If C < 2 Or C 8 Or R < 5 Or R 999 Then
Range("b5:h999").Interior.ColorIndex = 0 'color del fondo de la hoja
Exit Sub

Else

Range("b5:h999").Interior.ColorIndex = 0 'formato del fondo de la hoja
Range("b" & R & ":h" & R).Interior.ColorIndex = 24 'color de la fil
resaltante
End If
End Sub


Paste this code in the sheet you want to run it in the VB Exce
editor.

You can modify the range and color of cells. (In my code example th
color of cells change from B5:H5 to B999:H999).

regards,
Pedro Gutierrez
La Paz, BOLIVIA

--
pegbo
-----------------------------------------------------------------------
pegbol's Profile: http://www.excelforum.com/member.php...fo&userid=1670
View this thread: http://www.excelforum.com/showthread.php?threadid=31913


Bob Phillips[_6_]

Changing active cell to a color
 
Bob,

This is what I use

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.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
End With
.FormatConditions(1).Interior.ColorIndex = 20
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)


"Bob Reynolds" wrote in message
. ..
I have a need to have the active cell in my worksheet to be a highlighted
color for easy recognition. Is there a way to program whatever cell is
active to change to highlighted color and have the highlight move from

cell
to cell.
thanks in advance
Bob Reynolds





Bob Reynolds[_3_]

Changing active cell to a color
 
Soooo Simple. Thanks so much Don, that completely solved my problem. I
appreciate your help
Bob

"Don Guillett" wrote in message
...
Depending on version you may allow users to format cells. 3rd option on
xl2002. xl97 does not have this option.

--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in message
. ..
Hello again, thanks to all that responded I knew I could count on someone
helping but especially nice to get 3.

Don Guillett works great for an unprotected worksheet. !!!I have one
other
issue with this problem. The worksheet is protected so that when pressing
the tab button, only certain cells that are "unprotected" are accessible.
My problem is how do I leave the protection on to enable the specific

cells
to be tabbed to and maintain the color of the selected cell?
Can I use a macro to only allow the use of certain cells within the

workbook
and have the specific cells change color and protect and/or unprotect as
needed....
Hope I'm clear
Thanks
Bob Reynolds
"Don Guillett" wrote in message
...
This works well. Right click on sheet tabview codeinsert thisSAVE.
As written, does the entire row. Just change
Set MyRng = Target.EntireRow
to
Set MyRng = Target
for only one cell


'McCurdy.Here is something inspired by Don Guillett.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRng As Range
Set MyRng = Target.EntireRow
Application.EnableEvents = False
On Error GoTo end1
Application.Cells.FormatConditions.Delete
With MyRng
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ROW()=ROW(INDIRECT(CELL(""address"")))"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
.FormatConditions(1).Interior.ColorIndex = 36
End With
end1:
Application.EnableEvents = True
End Sub


--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in message
. ..
I have a need to have the active cell in my worksheet to be a

highlighted
color for easy recognition. Is there a way to program whatever cell is
active to change to highlighted color and have the highlight move from
cell
to cell.
thanks in advance
Bob Reynolds











Don Guillett[_4_]

Changing active cell to a color
 
glad to help

--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in message
.. .
Soooo Simple. Thanks so much Don, that completely solved my problem. I
appreciate your help
Bob

"Don Guillett" wrote in message
...
Depending on version you may allow users to format cells. 3rd option on
xl2002. xl97 does not have this option.

--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in message
. ..
Hello again, thanks to all that responded I knew I could count on

someone
helping but especially nice to get 3.

Don Guillett works great for an unprotected worksheet. !!!I have one
other
issue with this problem. The worksheet is protected so that when

pressing
the tab button, only certain cells that are "unprotected" are

accessible.
My problem is how do I leave the protection on to enable the specific

cells
to be tabbed to and maintain the color of the selected cell?
Can I use a macro to only allow the use of certain cells within the

workbook
and have the specific cells change color and protect and/or unprotect

as
needed....
Hope I'm clear
Thanks
Bob Reynolds
"Don Guillett" wrote in message
...
This works well. Right click on sheet tabview codeinsert thisSAVE.
As written, does the entire row. Just change
Set MyRng = Target.EntireRow
to
Set MyRng = Target
for only one cell


'McCurdy.Here is something inspired by Don Guillett.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRng As Range
Set MyRng = Target.EntireRow
Application.EnableEvents = False
On Error GoTo end1
Application.Cells.FormatConditions.Delete
With MyRng
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ROW()=ROW(INDIRECT(CELL(""address"")))"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
.FormatConditions(1).Interior.ColorIndex = 36
End With
end1:
Application.EnableEvents = True
End Sub


--
Don Guillett
SalesAid Software

"Bob Reynolds" wrote in

message
. ..
I have a need to have the active cell in my worksheet to be a

highlighted
color for easy recognition. Is there a way to program whatever cell

is
active to change to highlighted color and have the highlight move

from
cell
to cell.
thanks in advance
Bob Reynolds














All times are GMT +1. The time now is 03:34 AM.

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