Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Cell highlight

Hi,

Does anyone know of a way within excel to have a cell change colour (column
D) when it is simply clicked on. I want the user to simply click on a cell
in column D to have it change red and change back if clicked again.

Any suggestions??


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Cell highlight

There is no good way to accomplish this AFAIK. You can do it with a
double-click or a right-click but there is no click event for a worksheet.

--

Vasant


"gav meredith" wrote in message
...
Hi,

Does anyone know of a way within excel to have a cell change colour

(column
D) when it is simply clicked on. I want the user to simply click on a cell
in column D to have it change red and change back if clicked again.

Any suggestions??




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Cell highlight

not a problem, how would i do it with a double click??

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
There is no good way to accomplish this AFAIK. You can do it with a
double-click or a right-click but there is no click event for a worksheet.

--

Vasant


"gav meredith" wrote in message
...
Hi,

Does anyone know of a way within excel to have a cell change colour

(column
D) when it is simply clicked on. I want the user to simply click on a

cell
in column D to have it change red and change back if clicked again.

Any suggestions??






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Cell highlight

Put this in the code module of the worksheet:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Target, Range("D1:D20")) _
Is Nothing Then 'use your desired range
With Target.Font
If .Color = vbRed Then .Color = vbBlack Else .Color = vbRed
End With
End If
End Sub

Of course, since the double-click event is intercepted, the user will not be
able to edit the cell with a double-click.

--

Vasant



"gav meredith" wrote in message
...
not a problem, how would i do it with a double click??

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
There is no good way to accomplish this AFAIK. You can do it with a
double-click or a right-click but there is no click event for a

worksheet.

--

Vasant


"gav meredith" wrote in message
...
Hi,

Does anyone know of a way within excel to have a cell change colour

(column
D) when it is simply clicked on. I want the user to simply click on a

cell
in column D to have it change red and change back if clicked again.

Any suggestions??








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Cell highlight

again, thank you however this isnt exactly what i am after. I would like the
entire (blank) cell to have a red background. If you look at my other post
'alter existing code', you may have a better understanding. I really
appreciate this, thank you!!!!

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Put this in the code module of the worksheet:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Target, Range("D1:D20")) _
Is Nothing Then 'use your desired range
With Target.Font
If .Color = vbRed Then .Color = vbBlack Else .Color = vbRed
End With
End If
End Sub

Of course, since the double-click event is intercepted, the user will not

be
able to edit the cell with a double-click.

--

Vasant



"gav meredith" wrote in message
...
not a problem, how would i do it with a double click??

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
There is no good way to accomplish this AFAIK. You can do it with a
double-click or a right-click but there is no click event for a

worksheet.

--

Vasant


"gav meredith" wrote in message
...
Hi,

Does anyone know of a way within excel to have a cell change colour
(column
D) when it is simply clicked on. I want the user to simply click on

a
cell
in column D to have it change red and change back if clicked again.

Any suggestions??












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cell highlight

Hi Gav,

A slight amendment to Vasant's code

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Target, Range("D1:D20")) _
Is Nothing Then 'use your desired range
With Target.Interior
If .ColorIndex = 3 Then
.ColorIndex = xlColorIndexNone
Else
.ColorIndex = 3
End If
End With
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gav meredith" wrote in message
...
again, thank you however this isnt exactly what i am after. I would like

the
entire (blank) cell to have a red background. If you look at my other post
'alter existing code', you may have a better understanding. I really
appreciate this, thank you!!!!

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Put this in the code module of the worksheet:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Target, Range("D1:D20")) _
Is Nothing Then 'use your desired range
With Target.Font
If .Color = vbRed Then .Color = vbBlack Else .Color = vbRed
End With
End If
End Sub

Of course, since the double-click event is intercepted, the user will

not
be
able to edit the cell with a double-click.

--

Vasant



"gav meredith" wrote in message
...
not a problem, how would i do it with a double click??

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
There is no good way to accomplish this AFAIK. You can do it with a
double-click or a right-click but there is no click event for a

worksheet.

--

Vasant


"gav meredith" wrote in message
...
Hi,

Does anyone know of a way within excel to have a cell change

colour
(column
D) when it is simply clicked on. I want the user to simply click

on
a
cell
in column D to have it change red and change back if clicked

again.

Any suggestions??












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
How do I auto highlight a cell with the same data as another cell john talbot Excel Worksheet Functions 11 February 3rd 09 12:58 AM
how to highlight more related cells if cell highlight Jon Excel Discussion (Misc queries) 5 December 21st 08 01:06 PM
Highlight Cell Based Upon Referenced Cell Data Tee Excel Worksheet Functions 3 September 12th 08 05:26 PM
click on one cell to find and highlight a related cell? JustSomeGuy Excel Discussion (Misc queries) 1 September 3rd 07 03:02 PM
Highlight cells with ctrl-click but only un-highlight one cell hagan Excel Discussion (Misc queries) 5 May 27th 05 06:45 PM


All times are GMT +1. The time now is 12:41 PM.

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

About Us

"It's about Microsoft Excel"