Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    13
    Thanked 1 Time in 1 Post

    Newbie SOS: Sub Won't Run If Workbook Name Changes (Excel 2002)

    Here's an easy one (though not for me, yet) -- I've written a simple macro which works fine until you change the name of the workbook (which the recipient will probably do). How can I fix this? Here's the code:
    -----------------

    Sub AutoscaleProductionYAxis()
    '
    ' AutoscaleProductionYAxis Macro
    ' Macro recorded 12/01/2007 by Samsung
    '

    '
    ActiveSheet.ChartObjects("Chart 2615").Activate
    ActiveChart.ChartArea.Select
    ActiveChart.Axes(xlValue).Select
    With ActiveChart.Axes(xlValue)
    .MinimumScaleIsAuto = True
    .MaximumScaleIsAuto = True
    .MinorUnitIsAuto = True
    .MajorUnitIsAuto = True
    .Crosses = xlAutomatic
    .ReversePlotOrder = False
    .ScaleType = xlLinear
    .DisplayUnit = xlNone
    End With
    ActiveWindow.Visible = False
    Windows("Assigment 2 ver 092").Activate
    Range("p66").Select
    End Sub

    --------------------------------------

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Newbie SOS: Sub Won't Run If Workbook Name Changes (Excel 2002)

    I'm not sure why you hide a window in the macro. Does the following simplified version do what you want?

    Sub AutoscaleProductionYAxis()
    With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
    .MinimumScaleIsAuto = True
    .MaximumScaleIsAuto = True
    .MinorUnitIsAuto = True
    .MajorUnitIsAuto = True
    .Crosses = xlAutomatic
    .ReversePlotOrder = False
    .ScaleType = xlLinear
    .DisplayUnit = xlNone
    End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •