VBA code error

dan03uk

New Member
Joined
Mar 17, 2009
Messages
33
Need some help with this VBA code, I can't see why it doesn't work.

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Select Case Target.Address
    Case "$E$2"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _
            .MaximumScale = Target.Value
    Case "$E$3"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _
            .MinimumScale = Target.Value
    Case "$E$4"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _
            .MajorUnit = Target.Value
    Case "$F$2"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _
            .MaximumScale = Target.Value
    Case "$F$3"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _
            .MinimumScale = Target.Value
    Case "$F$4"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _
            .MajorUnit = Target.Value
    Case Else
End Select
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
In what way isn't it working?

The Workbook_SheetChange event applies to every sheet in the workbook. ActiveSheet can be replaced by Sh, which is passed as an argument to the procedure.

Is it the intention to monitor changes on every worksheet or just one? If the latter you should use the Worksheet_Change event procedure.
 
Upvote 0
Hi thanks fir the help. It only neeeds to be changed on the actuve sheet so I will give what you said ago.
 
Upvote 0
Hi thanks so much for your help i got it working, I was using the wrong address for the chart.
 
Upvote 0
One more wuick question is there away of stoping it from linking to ever sheet as it currently changes the axis on all sheets.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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