View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.charting
ers
 
Posts: n/a
Default Change scales from reference cells value for a chart in a separate sheet

Can anyone help me with this macro (my programming experience is very
limited).
I have a chart Chart4 on a sheet XY in the workbook erslOg_XxYx.
The same chart is in a separate sheet Chart2 on the same workbook (I
did that so I can print it easier).
The scale and the title is changed from reference cells from XY.
For the chart on the XY sheet is working fine, but is not for the chart
on separate sheet.
Last night I had the impression is working but now it is striking at:
..HasTitle = True
if I comment that it will execute (will change the title accordingly)
but it will strike at any row which makes reference to the cells in XY
sheet like:
..MinimumScale =
ThisWorkbook.Sheets("XY").Sheets("XY").Range("$e$4 1").Value

What is wrong with addressing those cells?
Thank you,
emil


-----------------------------------------------this is
working---------------------------------------------------------
Sub scales2()
' change scales on chart on the current sheet Macro

ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.Axes(xlValue).Select


With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Range("$c$1").Text
End With

With ActiveChart.Axes(xlCategory)
.MinimumScale = ActiveSheet.Range("$e$41").Value
.MaximumScale = ActiveSheet.Range("$e$42").Value
.MinorUnit = ActiveSheet.Range("$e$43").Value
.MajorUnit = ActiveSheet.Range("$e$44").Value
.Crosses = xlCustom
.CrossesAt = ActiveSheet.Range("$e$41").Value
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

With ActiveChart.Axes(xlValue)
.MinimumScale = ActiveSheet.Range("$h$42").Value
.MaximumScale = ActiveSheet.Range("$h$41").Value
.MinorUnit = ActiveSheet.Range("$h$43").Value
.MajorUnit = ActiveSheet.Range("$h$44").Value
.Crosses = xlCustom
.CrossesAt = ActiveSheet.Range("$h$42").Value
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
------------------------------------------------------this is not
working-------------------------------------------------

' change scales to the same but for chart on separate sheet Macro

ActiveWindow.Visible = False

Windows("erslOg_XxYy.XLS").Activate
Sheets("Chart2").Select

ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select


With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text =
ThisWorkbook.Sheets("XY").Range("$c$1").Text
End With

With ActiveChart.Axes(xlCategory)
.MinimumScale =
ThisWorkbook.Sheets("XY").Sheets("XY").Range("$e$4 1").Value
.MaximumScale = ThisWorkbook.Sheets("XY").Range("$e$42").Value
.MinorUnit = ThisWorkbook.Sheets("XY").Range("$e$43").Value
.MajorUnit = ThisWorkbook.Sheets("XY").Range("$e$44").Value
.Crosses = xlCustom
.CrossesAt = ThisWorkbook.Sheets("XY").Range("$e$41").Value
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

With ActiveChart.Axes(xlValue)
.MinimumScale = ThisWorkbook.Sheets("XY").Range("$h$42").Value
.MaximumScale = ThisWorkbook.Sheets("XY").Range("$h$41").Value
.MinorUnit = ThisWorkbook.Sheets("XY").Range("$h$43").Value
.MajorUnit = ThisWorkbook.Sheets("XY").Range("$h$44").Value
.Crosses = xlCustom
.CrossesAt = ThisWorkbook.Sheets("XY").Range("$h$42").Value
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

End Sub