Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default worksheet_change not working

I want to update some cells in a different worksheet (lets call it B)
when the value of a single cell changes in another (lets call it A). I
have inserted the code below into the worksheet_change event of
worksheet A, however when I change the value in C41 the values in
worksheet B don't change.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C41")) Is Nothing Then
Exit Sub
Else
Application.Worksheets("B").Range("B100:B108").Sel ect
Selection.ClearContents
Application.Worksheets("B").Range("B108").Select
ActiveCell.FormulaR1C1 = "=Water_TempSales"
Application.Worksheets("B").Range("B99:B108").Sele ct
Selection.DataSeries Rowcol:=xlColumns, Type:=xlGrowth,
Date:=xlDay, _
Trend:=True
End If

End Sub


I would appreciate some input as I am not a programmer by any stretch
of the imagination!

Thanks in advance,

Craig
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default worksheet_change not working

I've cleaned up your code a bit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myWS As Worksheet

If Intersect(Target, Range("C41")) Is Nothing Then
Exit Sub
End If

Set myWS = Worksheets("B")
'if the target value is in Worksheets("B") you could use the following
'Set myWS = Target.Parent

myWS.Range("B100:B108").ClearContents
myWS.Range("B108").FormulaR1C1 = "=Water_TempSales"
myWS.Range("B99:B108").DataSeries Rowcol:=xlColumns, Type:=xlGrowth,
Date:=xlDay, _
Trend:=True

End Sub

It worked fine for me. I wonder if your events aren't enabled. In the
Immediate window, put this

Application.Enableevents = TRUE

And try it again.
--
HTH,
Barb Reinhardt



"Craig F" wrote:

I want to update some cells in a different worksheet (lets call it B)
when the value of a single cell changes in another (lets call it A). I
have inserted the code below into the worksheet_change event of
worksheet A, however when I change the value in C41 the values in
worksheet B don't change.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C41")) Is Nothing Then
Exit Sub
Else
Application.Worksheets("B").Range("B100:B108").Sel ect
Selection.ClearContents
Application.Worksheets("B").Range("B108").Select
ActiveCell.FormulaR1C1 = "=Water_TempSales"
Application.Worksheets("B").Range("B99:B108").Sele ct
Selection.DataSeries Rowcol:=xlColumns, Type:=xlGrowth,
Date:=xlDay, _
Trend:=True
End If

End Sub


I would appreciate some input as I am not a programmer by any stretch
of the imagination!

Thanks in advance,

Craig

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
Worksheet_Change/macros not working Myriam Excel Programming 2 May 14th 07 10:10 PM
worksheet_change not working scottwilsonx[_63_] Excel Programming 0 October 22nd 04 05:07 PM
worksheet_change not working scottwilsonx[_62_] Excel Programming 0 October 22nd 04 05:06 PM
Worksheet_Change not working when using paste papou[_7_] Excel Programming 1 September 5th 03 12:57 PM
Worksheet_Change Event Not Working Michael Beckinsale Excel Programming 0 August 1st 03 02:43 PM


All times are GMT +1. The time now is 10:37 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"