Any wrong with this?

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
 
H

Harlan Grove

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..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Using macro to run repetitive tasks 1
Macro -- repetitive tasks 1
Straight Line is not straight 2
Help with graphs 9
Chart Macro Help Needed 1
Macro to Activate a Macro 6
ScaleType error 5
secondary Y axis 1

Top