K
KimberlyC
Hi,
After learning that the Worksheet Change Event doesn't alway trigger... I
added a formula to my worksheet the will calculate the cells that are being
changed...and I have moved this code below from the Worksheet_Change event
to the Worksheet_Calculate event inorder to get it to trigger every time a
cell is changed.
This code was working great in the Worksheet Change Event (just not all the
time), but now when I run it from the Worksheet Calculate event as shown
below..
I get an error message stating "Object Required" and it highlights this part
of the code (below) after clicking Debug :
If Not Application.Intersect(Target, _
Range("A8:A1000")) Is Nothing Then
I'm not sure why it's doing that....
********************************
Private Sub Worksheet_Calculate()
Dim prevSheet As Worksheet
With Me
If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If
.Unprotect Password:="test"
If Not Application.Intersect(Target, _
Range("A8:A1000")) Is Nothing Then
prevSheet.Range("A13:A100").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A1000"), prevSheet.Range("A13")
End If
.Unprotect Password:="test"
'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Application.ScreenUpdating = Ture
End Sub
Any help would be greatly appreciated!!
Thanks in advance!
Kimberly
After learning that the Worksheet Change Event doesn't alway trigger... I
added a formula to my worksheet the will calculate the cells that are being
changed...and I have moved this code below from the Worksheet_Change event
to the Worksheet_Calculate event inorder to get it to trigger every time a
cell is changed.
This code was working great in the Worksheet Change Event (just not all the
time), but now when I run it from the Worksheet Calculate event as shown
below..
I get an error message stating "Object Required" and it highlights this part
of the code (below) after clicking Debug :
If Not Application.Intersect(Target, _
Range("A8:A1000")) Is Nothing Then
I'm not sure why it's doing that....
********************************
Private Sub Worksheet_Calculate()
Dim prevSheet As Worksheet
With Me
If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If
.Unprotect Password:="test"
If Not Application.Intersect(Target, _
Range("A8:A1000")) Is Nothing Then
prevSheet.Range("A13:A100").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A1000"), prevSheet.Range("A13")
End If
.Unprotect Password:="test"
'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Application.ScreenUpdating = Ture
End Sub
Any help would be greatly appreciated!!
Thanks in advance!
Kimberly