LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default 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
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
How do I change the column heading in Excel to display "A" "B" "C Thai New Users to Excel 1 November 30th 07 08:06 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
=IF(D13="PAID","YES","NO") Can I change fonts colour Kev Excel Discussion (Misc queries) 3 February 17th 06 04:27 AM
Code to change the color of "Rectangle21_Click" Ed Excel Programming 2 September 29th 04 11:38 PM
VBA code to change the Print - "Number of copies" to 3 lothario[_34_] Excel Programming 3 October 27th 03 02:35 PM


All times are GMT +1. The time now is 04:01 AM.

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

About Us

"It's about Microsoft Excel"