Problem Calling A Sub When Using Worksheet_Change

dcunningham

Board Regular
Joined
Jul 14, 2015
Messages
58
Hi Everyone,

I'm trying to call a sub called ScaleAxes that sits in a module elsewhere. The ScaleAxes code is:

Code:
Option Explicit
Sub ScaleAxes()
  Worksheets("Dashboard").ChartObjects("Measure Chart").Activate
  With ActiveChart.Axes(xlCategory, xlPrimary)
    .MaximumScale = Sheets("Lists and Data").Range("R7").Value
    .MinimumScale = Sheets("Lists and Data").Range("Q7").Value
    .MajorUnit = Sheets("Lists and Data").Range("S7").Value
  End With
  With ActiveChart.Axes(xlValue, xlPrimary)
    .MaximumScale = Sheets("Lists and Data").Range("R9").Value
    .MinimumScale = Sheets("Lists and Data").Range("Q9").Value
    .MajorUnit = Sheets("Lists and Data").Range("S9").Value
  End With
End Sub

The code I'm trying to call it in is here:

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("H2:N2")
    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
        Is Nothing Then
        Dim addIn As COMAddIn
        Dim automationObject As Object
        Set addIn = Application.COMAddIns("PI DataLink")
            Set automationObject = addIn.Object
        Dim MyRange As Range
            Set MyRange = Range("J2")
            MyRange.Select
            automationObject.SelectRange
            automationObject.ResizeRange
            Application.CalculateFull
     End If
     If Not Application.Intersect(KeyCells, Range(Target.Address)) _
        Is Nothing Then
[COLOR=#ff0000]        Call ScaleAxes[/COLOR]
    End If
End Sub

ScaleAxes works on its own when I run it separately, and no error comes up when the code it's called in is run. The problem is that the code above seems to run properly, but the ScaleAxes code doesn't run.

Any help you can provide helping me remedy this issue would be appreciated.

Regards,

Dan
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,788
Messages
6,121,600
Members
449,038
Latest member
Arbind kumar

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