K
KimberlyC
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 A8500.
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 A8500 range.
Thanks in advance for your help!!
Kimberly
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 A8500.
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 A8500 range.
Thanks in advance for your help!!
Kimberly