Launch a Sub Worksheet_Change Event from inside a macro

  • Thread starter Thread starter Rolo
  • Start date Start date
R

Rolo

Hi all, thank you for your help.

Is it possible to launch the Sub Worksheet_Change Event from inside a macro?

I tried this but It doesn´t work

Sub Macro 1()
Sub Worksheet_Change Event
(rest of the code)
end sub

Thanks !
 
Rolo,

You can call the Worksheet_Change event procedure from another sub in a
standard code module. First, change the Private keyword to Public, then
call the sub with code like

Sheet1.Worksheet_Change Range("A1")

Change "Sheet1" to the VBA codename (not the worksheet name) of the
appropriate sheet.

A better, more structured, way is to put the code that currently resides in
Worksheet_Change in another procedure in a standard code module and call
that procedure. E.g,.

[in a standard code module]
Sub DoSomething (ByVal Target As Range)
' whatever
End Sub

[in the sheet module]
Public Sub Worksheet_Change(ByVal Target As Excel.Range)
DoSomething Target:=Target
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Back
Top