Worksheet_Change event issue. Fundamental problem?

rdsmit1

Board Regular
Joined
Apr 19, 2010
Messages
194
Below is my code... I recorded a macro which works fine and does what I want if I click run macro, but then I tried making it execute after a change is made to the active sheet and I get an error: "Compile error: Ambiguous name detected: Worksheet_Change"

I think that I am doing something really fundamentally wrong like (ByVal Target As Range) is not correct.... I'm not really sure what I need in the parentheses after Private Sub Worksheet_Change(???).

Thanks!



Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.ChartObjects("Chart 243").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("setup-smry").Range("=OFFSET('setup-smry'!$B$224,0,0,1+MAX('setup-smry'!$B$140:$AE$140),30)"), _
PlotBy:=xlRows

End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Sounds to me like you have two Worksheet_Change() macros in this module - so I would check to make sure you have not duplicated them
 
Upvote 0
Yes that was the problem, Thanks!

But also to help better understand VBA could someone explain what is supposed to be in the parenthesis after Private Sub Worksheet_SelectionChange(???)? <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 
Upvote 0
ByVal Target As Range

The above is defined by whomever wrote the code behind the Worksheet_change (I mean the Excel program team, not the end user). You should never have need to change it - just go with whatever is created when you select whichever event you want to hook into by selecting the event in the right hand dropdown of the sheet module.
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top