View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier[_2_] Jon Peltier[_2_] is offline
external usenet poster
 
Posts: 461
Default how to superimpose chart images or extract data by vba

Here's part 2:

Macro to extract data from a chart in Excel
http://support.microsoft.com/kb/300643

Part 1 may be satisfied by creating a combination chart. What types of
chart are you trying to superimpose?

Actually superimposing one chart on another, requires you to equalize
the left and top positions and the width and height dimensions of the
two chart objects. You may also need to equalize these parameters for
the plot areas as well.

''''''''''''''''''''''''''''''' snippet

Dim cht1 As ChartObject
Dim cht2 As ChartObject

Set cht1 = ActiveSheet.ChartObjects(1)
Set cht2 = ActiveSheet.ChartObjects(2)

' equalize chart size and position
cht2.Left = cht1.Left
cht2.Top = cht1.Top
cht2.Width = cht1.Width
cht2.Height= cht1.Height

' temporarily shrink plot area
cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2
cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2

' equalize plot area size and position
cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left
cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top
cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width
cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height

''''''''''''''''''''''''''''''' end snippet

Long ago I posted a small utility to do this on my web site:

Align Excel Charts Using VBA
http://peltiertech.com/Excel/Charts/AlignCharts.html

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



Davyboom wrote:
how to superimpose 2 charts or extract data by vba