Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default More then 1 Private Sub Worksheet_Change

HI,

can i have ore then 1 "Worksheet_Change" sub?

i.e

I havea sub, Private Sub Worksheet_Change

but, Private Sub Worksheet2_Change

will not work

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default More then 1 Private Sub Worksheet_Change

No. but you can combine. As ALWAYS, post your code for comments.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:9ff261acc54dc@uwe...
HI,

can i have ore then 1 "Worksheet_Change" sub?

i.e

I havea sub, Private Sub Worksheet_Change

but, Private Sub Worksheet2_Change

will not work

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default More then 1 Private Sub Worksheet_Change

Not fot the same sheet. However, you can have the worksheet change do more
than one thing by using If...Then statements. For example:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Worksheet
Set sh = ActiveSheet
If sh.Range("A1").Value 0 Then
'Do one thing
End If
If sh.Target.Value = "Do Something" Then
'Do another
End If
If Not Intersect(sh.Selection, Target) Is Nothing Then
"Do somethiing else
End If
End Sub

Only when the If statement is true will the code execute a command to do
something. If none of them are true then it executes no commands. If all
of them are true it executes all three commands.





"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:9ff261acc54dc@uwe...
HI,

can i have ore then 1 "Worksheet_Change" sub?

i.e

I havea sub, Private Sub Worksheet_Change

but, Private Sub Worksheet2_Change

will not work

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default More then 1 Private Sub Worksheet_Change

No, you will just have to combine the code you want in your two Change
events into the Change event that VB provides. You can use If..Then blocks
to separate the functionality you wanted in your proposed separate Change
events.

--
Rick (MVP - Excel)


"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:9ff261acc54dc@uwe...
HI,

can i have ore then 1 "Worksheet_Change" sub?

i.e

I havea sub, Private Sub Worksheet_Change

but, Private Sub Worksheet2_Change

will not work

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1


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
Private Sub Worksheet_Change code not robust enough GI Excel Programming 2 July 31st 09 09:54 PM
Private Sub Worksheet_change ... Procedures jamming up BEEJAY Excel Programming 5 October 25th 08 11:51 AM
Private Sub Worksheet_Change doesn't work? Sam Kuo[_3_] Excel Programming 2 March 9th 08 08:57 PM
Private Sub Worksheet_Change(ByVal Target As Range) Paige Excel Programming 1 May 17th 07 12:16 AM
Private Sub Worksheet_Change(ByVal Target As Range) pd1234321 Excel Programming 5 December 8th 06 04:11 AM


All times are GMT +1. The time now is 01:02 PM.

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

About Us

"It's about Microsoft Excel"