Multiple graphics

  • Thread starter Thread starter Manuel Nilo
  • Start date Start date
M

Manuel Nilo

Hi to everybody:

I want to present in a spreadsheet two graphics (line style)

- One will be under the other
- Both have the same number of data
- both have diferent scales in the vertical axe (because everyone shows
different variables)

How can I do that every point in the top graphic is exactly on top of the
same point in the down graphic without doing it by hand or adjusting it with
the mouse everytime I change the data?

thanks in advance

--


--
______________________________

Manuel Nilo
(e-mail address removed)
______________________________
 
Manuel -

Can you put both series into the same chart, and use secondary axes for
one of the series?

Otherwise you need a macro. Here's one I've used to make the width and
height of the plotting rectangles of all charts the same size:

Sub AllTheSameInside()
'' Select a chart, then run
Dim cht As Chart
Dim chtob As ChartObject
Dim chtobHt As Double
Dim chtobWd As Double
Dim chtobLf As Double
Dim chtobTp As Double
Dim pltarHt As Double
Dim pltarWd As Double
Dim pltarLf As Double
Dim pltarTp As Double
Dim pltarInRt As Double
Dim pltarInBt As Double
Dim pltarInHt As Double
Dim pltarInWd As Double
Dim pltarInLf As Double
Dim pltarInTp As Double

If Not ActiveChart Is Nothing Then
ActiveWindow.Visible = False
End If

'' Hide the action to prevent dizziness
'' and speed it up dramatically
Application.ScreenUpdating = False

'' Cycle through charts on worksheet to get parameters
For Each chtob In ActiveSheet.ChartObjects
With chtob.Chart
'' Get extreme plotarea inside parameters
pltarInHt = WorksheetFunction.Min(pltarInHt, _
.PlotArea.InsideHeight)
pltarInLf = WorksheetFunction.Max(pltarInLf, _
.PlotArea.InsideLeft)
pltarInTp = WorksheetFunction.Max(pltarInTp, _
.PlotArea.InsideTop)
pltarInWd = WorksheetFunction.Min(pltarInWd, _
.PlotArea.InsideWidth)
pltarInRt = WorksheetFunction.Max(pltarInRt, _
.ChartArea.Width - .PlotArea.InsideLeft - _
.PlotArea.InsideWidth)
pltarInBt = WorksheetFunction.Max(pltarInBt, _
.ChartArea.Height - .PlotArea.InsideTop - _
.PlotArea.InsideHeight)
End With
Next

'' Cycle through charts on worksheet to set parameters
For Each chtob In ActiveSheet.ChartObjects
With chtob
'' Get initial position
chtobLf = .Left
chtobTp = .Top

'' Move to avoid XL97 PlotArea problems
.Left = ActiveSheet.Columns _
(ActiveWindow.ScrollColumn).Left + 10
.Top = ActiveSheet.Rows _
(ActiveWindow.ScrollRow).Top + 10

'' Fix Font Size
.Chart.ChartArea.AutoScaleFont = False

'' '' Apply chart object size
'' .Width = chtobWd
'' .Height = chtobHt

'' Apply plotarea parameters
With .Chart
'' Determine parameters
pltarLf = .PlotArea.Left + pltarInLf - _
.PlotArea.InsideLeft
pltarTp = .PlotArea.Top + pltarInTp - _
.PlotArea.InsideTop
pltarWd = .PlotArea.Width - _
(pltarInLf - .PlotArea.InsideLeft) - _
(pltarInRt - (.ChartArea.Width - _
.PlotArea.InsideLeft - .PlotArea.InsideWidth))
pltarHt = .PlotArea.Height - _
(pltarInTp - .PlotArea.InsideTop) - _
(pltarInBt - (.ChartArea.Height - _
.PlotArea.InsideTop - .PlotArea.InsideHeight))
With .PlotArea
'' Shrink it so it can move anywhere
.Height = pltarHt / 3
.Width = pltarWd / 3
.Top = pltarTp
.Left = pltarLf
.Height = pltarHt
.Width = pltarWd
End With
End With

'' Move back to initial position
.Left = chtobLf
.Top = chtobTp
End With
Next

'' Unhide the action
Application.ScreenUpdating = True
End Sub

- Jon
 
Ok Jon, I will use the macro because I will need to use at least two charts.

Thanks.



--
______________________________

Manuel Nilo
(e-mail address removed)
______________________________
 
Back
Top