ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Any wrong with this? (https://www.excelbanter.com/excel-discussion-misc-queries/152806-any-wrong.html)

Jo[_2_]

Any wrong with this?
 
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


Harlan Grove

Any wrong with this?
 
Jo wrote...
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..



All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com