View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Script Not working

My guess is that the code the OP is currently using won't run on a protected
sheet either, so I would think the RowLiner Add-In solution should still be
a viable choice.

--
Rick (MVP - Excel)


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Dave and Rick

My first instinct was to direct OP to the rowliner add-in which is not
destructive as the OP code is.

The only catch I find with rowliner is it won't run on a protected
worksheet.

The AppEvent suggestion was for an exercise only.


Gord

On Sat, 06 Sep 2008 11:08:39 -0500, Dave Peterson
wrote:

I agree with you Gord (still not your wife, though <vbg)...

This code would go into the ThisWorkbook module of the addin (that's
always
opened when excel opens).

Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub Workbook_Close()
Set xlApp = Nothing
End Sub
Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
Target.Parent.Cells.Interior.ColorIndex = xlNone
With Target
.EntireRow.Interior.ColorIndex = 40
.EntireColumn.Interior.ColorIndex = 36
End With
End Sub

Personally, I wouldn't use this. It's not robust enough to clean up after
itself and I wouldn't want to see any of my nicely formatted (pretty
colors!)
worksheets be screwed up by this.

Instead, I'd try Chip Pearson's addin:
http://www.cpearson.com/excel/RowLiner.htm

I'm sure he's thought this stuff out way more than I have.


Gord Dibben wrote:

Rick

OP wants to have the code in an add-in to make it available for all open
workbooks/sheets.

Wouldn't that have to be done through Application Event in the add-in?

I'm not sure how to achieve that.

I've been browsing Chip's site but can't get anything to work with my
limited skills.

http://www.cpearson.com/excel/AppEvent.aspx

Gord

On Sat, 6 Sep 2008 11:16:10 -0400, "Rick Rothstein"
wrote:

To Esssa and Gary''s Student...

Better would be to remove the code from the current SelectionChange
event
procedure and put it in the workbook's SheetSelectionChange event
instead,
then it would apply to every worksheet in the workbook.

To Esssa...

Take the code out of your current SelectionChange event, double click
the
ThisWorkbook entry in the Project Window on the left, choose Workbook
from
the code window's left hand drop down and SheetSelectionChange from its
right hand drop down an place the code in there.