I am trying to set the maximum value for the x-axis of my chart based on the value I enter into a cell.
I am using the following VBA code under a worksheet change event:
When I change the value in cell C1, I get a Run-time error 13 and the message 'Type mismatch'. Can anyone shed some light on what may be causing this error?
I am trying to do this with a XY scatter graph.
Thanks.
I am using the following VBA code under a worksheet change event:
Code:
Option Explicit
x1Category As Range
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$1"
ActiveSheet.ChartObjects("Chart 1").Chart.Axes(x1Category) _
.MaximumScale = Target.Value
Case Else
End Select
End Sub
When I change the value in cell C1, I get a Run-time error 13 and the message 'Type mismatch'. Can anyone shed some light on what may be causing this error?
I am trying to do this with a XY scatter graph.
Thanks.