Any wrong with this?

  • Thread starter Thread starter Jo
  • Start date Start date
J

Jo

I have this piece of code:

With ActiveChart.Axes(xlValue)
.MinimumScale = BaseCPM
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

In the 2nd row of the code, BaseCPM is a cell name where I want the
macro to update that value.

It is not working right?

Jo
 
Jo said:
I have this piece of code:

With ActiveChart.Axes(xlValue)
.MinimumScale = BaseCPM
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

In the 2nd row of the code, BaseCPM is a cell name where I want the
macro to update that value.
....

VBA will treat BaseCPM as a VBA variable rather than as a name. Also,
the code above sets ActiveChart.Axes(xlValue).MinimumScale to BaseCPM
rather than updating BaseCPM with anything.

If this is a defined name in the workbook, you need to use

.MinimumScale = Names("BaseCPM").RefersToRange.Value

or

.MinimumScale = Evaluate("BaseCPM")

To change the value of the cell to which BaseCPM refers, use

Names("BaseCPM").RefersToRange.Value = ..whatever..
 
Back
Top