Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem w/code to copy worksheet to new workbook | Excel Programming | |||
run code on opening workbook and apply code to certain sheets | Excel Programming | |||
Inserting a worksheet into an open workbook via VBA code | Excel Programming | |||
specifying workbook for worksheet code name | Excel Programming | |||
Copy worksheet, code and all, into workbook? | Excel Programming |