input box cancel button

  • Thread starter Thread starter Ian Mangelsdorf
  • Start date Start date
I

Ian Mangelsdorf

I am using an input box to get a value for changing the axis on every
chart in a worksheet. I works fine but when cancel is hit I get a
strange result.

how can Improve the code below so a cancel hit will return to the
worksheet with no change

Sub set_axis()
Dim ch As ChartObject
mindepth = Application.InputBox(prompt:="Please Enter The Top Depth
for the Plot")
maxdpeth = mindpeth + 60
For Each ch In ActiveSheet.ChartObjects
With ch.Chart.Axes(xlValue)
.MinimumScale = mindepth
.MaximumScale = mindepth + 60
.ReversePlotOrder = True
.CrossesAt = mindepth
End With
Next
ActiveSheet.Name = "Core Plot " & mindepth & "m"


End Sub

Cheers

Ian
 
Ian,

One way

If Len(mindepth) > 0 then
* your code *
End If

This works even if something is entered into the input box.
 
Back
Top