Run Event Code In General Module

  • Thread starter Thread starter Who I Am
  • Start date Start date
W

Who I Am

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

ActiveCell.EntireRow.Interior.ColorIndex = 6

If z = Empty Then
ElseIf Not z = ActiveCell.Row Then
Rows(z).EntireRow.Interior.ColorIndex = xlColorIndexNone
End If

z = ActiveCell.Row

End Sub

I run this code with a worksheet. It is perfect. Can I put this code
(or new version) in a module so I can run it in any active sheet, any
active workbook?

Thanks
 
Event code can not be placed in a standard module. However what you want to
do has been taken care of in thisworkbook. The code will look like this...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

End Sub

That being said take a look at Chip's row highliter. It is kinda cool...

http://www.cpearson.com/excel/excelM.htm#HighlightActiveCell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top