Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Launch a Sub Worksheet_Change Event from inside a macro

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 !
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Launch a Sub Worksheet_Change Event from inside a macro

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


"Rolo" wrote in message
om...
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 !



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
Controling the Worksheet_Change Event? DCSwearingen Excel Discussion (Misc queries) 3 May 25th 06 08:32 PM
Worksheet_Change Event - Macro kills copy and paste Alan Excel Programming 5 September 23rd 03 02:58 AM
Worksheet_Change event question marwan hefnawy Excel Programming 1 September 10th 03 08:53 PM
Worksheet_Change Event Not Working Michael Beckinsale Excel Programming 0 August 1st 03 02:43 PM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"