Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Worksheet Change code not running when you just delete data in cells.

Hi,
I'm using the following code below (which is placed in the Workheet - Change
Module of the active worksheet) to create a list of codes on the previous
worksheet from the active worksheet. If a code is repeated numerous times on
the active worksheet, it only gets listed once on the previous worksheet.
It's working good, except when I press the delete key to remove codes..the
list on the previous worksheet does not change.. infact if I delete the
entire list on the active worksheet, there is no change on the previous
worksheet..the codes are still there..when they should be gone since I
deleted them from the active worksheet.

How can I get this code to run when the user just presses the delete key to
remove codes on the activeworksheet?
Using the delete key seems to not trigger the worksheet change code to run..


Private Sub Worksheet_Change(ByVal Target As Range)
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


Thanks in advance,
Kimberly


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
Running code on a drop down selection change Steve Haack Excel Worksheet Functions 1 April 26th 05 05:03 AM
Problem with Running VBA code on Cell Change Marty Excel Programming 8 January 18th 05 04:01 AM
make macro change (delete) its own code as_sass Excel Programming 4 August 26th 04 07:15 PM
Running Code in an XLA from a Worksheet Chrissy[_4_] Excel Programming 6 October 11th 03 11:27 PM
Delete Code from Worksheet JohnV[_3_] Excel Programming 2 September 13th 03 03:55 AM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"