Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CW CW is offline
external usenet poster
 
Posts: 54
Default How do I highlight the active cell in a spreadsheet?

I want the active cell to change color.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default How do I highlight the active cell in a spreadsheet?

Hi, CW,

Try pasting this into the code window of the worksheet for which you want to
highlight the active cell.
Change the "22" value in the sixth line to change the colour of the highlight.
Hope this helps

Pete

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 22
End With
End Sub


"CW" wrote:

I want the active cell to change color.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I highlight the active cell in a spreadsheet?


Hi,

The below is also pasted into the worksheet's code, but this allow for
any conditional formatting etc that already exists on the sheet to be
returned after the active cell is changed rather than deleted as Pete's
option does with "Cells.FormatConditions.Delete".

Check out the link below for further info/instructions.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'sourced from
http://www.mcgimpsey.com/excel/highl...iteRetainColor
Const cnNUMCOLS As Long = 10 'if this is 256 it is all columns
but macro is slower
Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long
Dim i As Long
If Not rOld Is Nothing Then 'Restore color indices
With rOld.Cells
If .Row = ActiveCell.Row Then Exit Sub 'same row, don't
restore
For i = 1 To cnNUMCOLS
..Item(i).Interior.ColorIndex = nColorIndices(i)
Next i
End With
End If
Set rOld = Cells(ActiveCell.Row, 1).Resize(1, cnNUMCOLS)
With rOld
For i = 1 To cnNUMCOLS
nColorIndices(i) = .Item(i).Interior.ColorIndex
Next i
..Interior.ColorIndex = cnHIGHLIGHTCOLOR
End With
End Sub

Hth,
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=520284

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
How do I get row and column of active cell to highlight? chappi Excel Discussion (Misc queries) 2 August 19th 09 10:21 PM
Active Cell Highlight Bill_17256 Excel Discussion (Misc queries) 6 April 24th 09 11:00 PM
Active cell highlight E Excel Discussion (Misc queries) 21 February 15th 08 09:40 PM
Highlight Active Cell Db1712 Excel Discussion (Misc queries) 1 November 26th 04 01:14 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"