Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default On Change Event and Intersect

Your code should be in the sheet rather than in ThisWorkbook. Right click the
sheet tab and select view code. Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
If Target.Count 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("C13:C22")) Is Nothing Then _
Target.Offset(0, 2).Value = Target.Value * Target.Offset(0, 1).Value
ErrorHandler:
Application.EnableEvents = True
End Sub

Note that there are a couple of changes. If more than a single cell was
changed then nothing happens. If the change occured in C13:C22 then it turns
off events and makes the change which keeps the code from making a recursive
call based in the change that the code makes.
--
HTH...

Jim Thomlinson


"headly" wrote:

Have code that reads (thanks to ozgrid)

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Not Intersect(Target, Range("c13:c22")) Is Nothing Then
ActiveCell.Offset(0, 2).Value = ActiveCell.Value * ActiveCell.Offset(0,
1).Value
End If

but that effects the range c13:c22 on all sheets; How do I keep it specific
to a particular sheet?

TIA

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
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
Change event and calculate event Antje Excel Programming 1 March 29th 05 09:03 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM


All times are GMT +1. The time now is 12:57 PM.

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"