View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann
 
Posts: n/a
Default Active cell highlight

"Sandy Mann" wrote in message
...
from the formula bar. Also it seems to work just as well if I comment out
the IF and End If lines and just leave the:

OldCell.Interior.ColorIndex = xlColorIndexNone


Ah! there is a reason for those lines! I tried recording a Macro of copying
from the Formula Bar and got only:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/12/2005 by Sandy Mann
'

'
Range("H8").Select
ActiveSheet.Paste
End Su

If I then select a cell and copy it, (not from the Formula Bar this time,)
and run the Macro it fails with

Error 1004 "Paste method of worksheet class failed" and highlights the
"ActiveSheet.Paste" line in Macro1, presumably because there is nothing to
paste.

OK all very logical but now if I Debug and End to exit from VBA, every time
I select a new cell I get a Runtime error 91 "Object variable of worksheet
class failed" and it highlights the "OldCell.Interior.ColorIndex =
xlColorIndexNone" line in the Event Macro and continues to do so until I
remove apostrophes from the commented out lines.

mmmmm...... there's more to this VBA than meets the eye <g


--

Sandy

Replace@mailinator with @tiscali.co.uk


"Sandy Mann" wrote in message
...
Gord,

Oddly enough it the paste functionality remains for me in XL95 if I copy
from the formula bar. Also it seems to work just as well if I comment out
the IF and End If lines and just leave the:

OldCell.Interior.ColorIndex = xlColorIndexNone

By itself

--
Regards


Sandy

Replace@mailinator with @tiscali.co.uk


"Gord Dibben" <gorddibbATshawDOTca@ wrote in message
...
Chuck

You've done nothing wrong.

I have never been able to get the copy/paste function back using this
code.

Tried wrapping in eneableevents true and false, but no joy.

Chip's rowliner add-in makes provision for this by highlighting only a
portion
of the activecell so's you can right-click or double-click on the
unhighlighted portion for copy/paste etc.

Best to go with that unless someone will jump in with a fix for the code
I
posted(which was from Chip long time past).


Gord

On Mon, 12 Dec 2005 11:53:02 -0800, CLR
wrote:

Hi Gord............

This code works neat, except I seem to have lost the ability to
CopyAndPaste..........what might I have done wrong?

Vaya con Dios,
Chuck, CABGx3



"Gord Dibben" wrote:

E

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static OldCell As Range
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
End If
Target.Interior.ColorIndex = 6
Set OldCell = Target
End Sub

This is worksheet event code.

Right-click on the sheet tab and "View Code"

Copy and paste the code above into that module.

Alternative..............

Go to Chip Pearson's site and downloas his Rowliner Add-in so's you can
have
the highlighting available for all open workbooks and sheets.

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


Gord Dibben Excel MVP

On Mon, 12 Dec 2005 08:29:03 -0800, "E"
wrote:

Hi,

I would like to know if there was a way to have an active cell always
in
yellow or any color.

Example: If the active cell is moved around, the active cell will be
always
in yellow.

Thank you in advance