View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Can Worksheet_Change run from separate module?

A better option generally speaking is to change Me to
Target.parent

Parent is the sheet that the range came from.
--
HTH...

Jim Thomlinson


"Horatio J. Bilge, Jr." wrote:

Thanks! That seems to work great. The only change I had to make in the code
was to change the Me object to ActiveSheet.

~ Horatio

"Jim Thomlinson" wrote:

Yes. You may need to modify your code depending on what it does and how it
does it...

'In the sheet
Private Sub Worksheet_Change(ByVal Target As Range)
Call Module1.DoStuff(Target)
End Sub

'In Module1
Public Sub DoStuff(ByVal Target As Range)
MsgBox Target.Parent.Name
End Sub
--
HTH...

Jim Thomlinson


"Horatio J. Bilge, Jr." wrote:

I have a worksheet ("MySheet") with about 300 lines of code in the
Worksheet_Change event. When a user opens the workbook, MySheet will be
copied as many times as the user indicates (maybe up to 30-40 times). As a
result, my 300 lines of code goes up to about 12,000 lines.

I am wondering if it is possible to put the code into a separate module, and
then use the Worksheet_Change event to call the code from that other module.

~ Horatio