Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet Change "code"
Hi
I'm using the following code that is executed when there is a change to the worksheet ( With the help of this group.....thank you!!) Private Sub Worksheet_Change(ByVal Target As Range) With ActiveSheet If .Index = 1 Then MsgBox "No sheets to the left" Else Set mysheet = Worksheets(.Index - 1) End If End With ActiveSheet.Unprotect Password:="test" If Not Application.Intersect(Target, _ Range("A8:A501")) Is Nothing Then mysheet.Range("a8:a47").ClearContents gCopyUnique Range("A8:A501"), mysheet.Range("A8") End If ActiveSheet.Unprotect Password:="test" mysheet.Range("A8:A47").Sort Key1:=mysheet.Range("A8"), Order1:=xlDescending, Header:=xlGuess _ , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom ActiveSheet.Protect Password:="test", DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Here's my problem: I only want this code to run when certain cells are changed on the worksheet. The range of cells is A8:P500. Not sure if this is possible...but... The reason for this...is .... I am running code that copies add'l worksheets to a template file from an addin file. The worksheets being copied have the same code above behind the worksheets.....which is fine.....but..there is add'l code that runs when these worksheets are copied to the active workbook that poplulates certain cells in these worksheets....which casues the "worksheet change" code to run and this casues all kinds errors...as it's trying to sort worksheets that it's not and so on.. So.. I'm thinking if I could just run the code only if certain cells are changed...that would eliminate the erros when the other code runs to poplulate the cells when they are copied from the addin file...as these cells would not be in the A8:P500 range. Thanks in advance for your help!! Kimberly |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I change the column heading in Excel to display "A" "B" "C | New Users to Excel | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
=IF(D13="PAID","YES","NO") Can I change fonts colour | Excel Discussion (Misc queries) | |||
Code to change the color of "Rectangle21_Click" | Excel Programming | |||
VBA code to change the Print - "Number of copies" to 3 | Excel Programming |