PC Review


Reply
Thread Tools Rate Thread

Changing cell colour when cell selected/de-selected by mouse/arrow keys

 
 
Joe Hannett
Guest
Posts: n/a
 
      2nd Aug 2004
Newbie. Is it possible to get excel to change the colour
of a cell when it is selected by mouse pointer, or arrow
keys, from default white to yellow then revert to white
again when the next cell is selected?
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      2nd Aug 2004
Here's one way

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
.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 = 6
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

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

"Joe Hannett" <(E-Mail Removed)> wrote in message
news:98ff01c478ac$ec3634e0$(E-Mail Removed)...
> Newbie. Is it possible to get excel to change the colour
> of a cell when it is selected by mouse pointer, or arrow
> keys, from default white to yellow then revert to white
> again when the next cell is selected?



 
Reply With Quote
 
Frank Kabel
Guest
Posts: n/a
 
      2nd Aug 2004
Hi

see:
http://www.cpearson.com/excel/RowLiner.htm

But this kind of event procedure will disbable the UNDO functionality
--
Regards
Frank Kabel
Frankfurt, Germany


Joe Hannett wrote:
> Newbie. Is it possible to get excel to change the colour
> of a cell when it is selected by mouse pointer, or arrow
> keys, from default white to yellow then revert to white
> again when the next cell is selected?

 
Reply With Quote
 
=?Utf-8?B?TGFuY2VC?=
Guest
Posts: n/a
 
      2nd Aug 2004
You could use an event macro


Dim OLDCOLOR As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not (OLDCOLOR Is Nothing) Then OLDCOLOR.Interior.ColorIndex = 0
Target.Interior.ColorIndex = 6
Set OLDCOLOR = Target

End Sub




"Joe Hannett" wrote:

> Newbie. Is it possible to get excel to change the colour
> of a cell when it is selected by mouse pointer, or arrow
> keys, from default white to yellow then revert to white
> again when the next cell is selected?
>

 
Reply With Quote
 
Joe Hannett
Guest
Posts: n/a
 
      12th Aug 2004
Mr Bob Phillips,

Sir you are a gentleman and a scholar. It worked like a charm. Thank
you from my - nearsighted - manager and I! Your help is truly
appreciated.

Joe Hannett.

"Bob Phillips" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Here's one way
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Cells.FormatConditions.Delete
> With Target
> .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 = 6
> 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
>
> Bob Phillips
> ... looking out across Poole Harbour to the Purbecks
> (remove nothere from the email address if mailing direct)
>
> "Joe Hannett" <(E-Mail Removed)> wrote in message
> news:98ff01c478ac$ec3634e0$(E-Mail Removed)...
> > Newbie. Is it possible to get excel to change the colour
> > of a cell when it is selected by mouse pointer, or arrow
> > keys, from default white to yellow then revert to white
> > again when the next cell is selected?

 
Reply With Quote
 
Joe Hannett
Guest
Posts: n/a
 
      12th Aug 2004
Thank you for this info Mr Kabel.

As my manager (for whom I have been trying to figure this out for
months) was unaware of even the UNDO facility (!) I reckon this won't
be a problem.

Kind regards
Joe Hannett


"Frank Kabel" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Hi
>
> see:
> http://www.cpearson.com/excel/RowLiner.htm
>
> But this kind of event procedure will disbable the UNDO functionality
> --
> Regards
> Frank Kabel
> Frankfurt, Germany
>
>
> Joe Hannett wrote:
> > Newbie. Is it possible to get excel to change the colour
> > of a cell when it is selected by mouse pointer, or arrow
> > keys, from default white to yellow then revert to white
> > again when the next cell is selected?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change selected cell shading colour Chas Microsoft Excel Misc 2 7th Jul 2009 06:54 PM
Change text colour of a cell when a different cell is selected gregglazar@gmail.com Microsoft Excel Programming 3 17th Jul 2006 08:26 AM
Drop-down arrow only visible when cell selected John Richards Microsoft Excel Discussion 2 4th Mar 2005 11:40 AM
Changing the colour of a cell when it is selected? Rizitsu Microsoft Excel Misc 3 24th Nov 2004 02:59 PM
Selected Cell Colour John T. Riordan Microsoft Excel Worksheet Functions 3 4th Dec 2003 12:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:13 PM.