Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Workbook code vs worksheet code

Hi-This code works when in This Workbook section for code but I want
to have it work in one worksheet only. I tried just copying the code
the the specifc worksheet. Didn't work. What do I change?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Target.Interior.Color = vbRed
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Workbook code vs worksheet code

Dean,
With events that are built-in to the object in Excel or those you define,
you will find it more reliable to get VBA to generate the stubs for you,
thereby guaranteeing that the signature, arguments etc are correct.
In the WS module that you wish to add the code, go to the top-left combo box
and select "WorkSheet". Then in the top-right combo box, select the event
you want, in this case "Change".

Now add your desired code in the routine.

NickHK

wrote in message
ups.com...
Hi-This code works when in This Workbook section for code but I want
to have it work in one worksheet only. I tried just copying the code
the the specifc worksheet. Didn't work. What do I change?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Target.Interior.Color = vbRed
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Workbook code vs worksheet code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name < "LastOne" Then End
Target.Interior.Color = vbRed
End Sub

Change the sheet name to the one you want this to run.


Regards
Robert McCurdy
wrote in message ups.com...
Hi-This code works when in This Workbook section for code but I want
to have it work in one worksheet only. I tried just copying the code
the the specifc worksheet. Didn't work. What do I change?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Target.Interior.Color = vbRed
End Sub

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
Problem w/code to copy worksheet to new workbook ploddinggaltn Excel Programming 9 October 29th 06 10:00 PM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
Inserting a worksheet into an open workbook via VBA code manillla Excel Programming 2 June 14th 05 01:30 AM
specifying workbook for worksheet code name Doug Glancy Excel Programming 7 January 25th 04 12:00 AM
Copy worksheet, code and all, into workbook? Ed[_9_] Excel Programming 2 September 22nd 03 03:11 PM


All times are GMT +1. The time now is 10:21 AM.

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"