Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Charting / August 2006

Tip: Looking for answers? Try searching our database.

plot graph from multiple worksheet as embedded chart object on every worksheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffrey.Tiong@gmail.com - 22 Aug 2006 22:42 GMT
Hi i want to plot the graph for every worksheet (column B and column
D). I have more than 50 worksheets in the same workbook. How do i write
a macro to ask the excel to plot the graph for every sheet and present
the chart object on the same sheet? thank you very much for your help!
i have been working on this over 2 days still cannot figure it out...
Jon Peltier - 24 Aug 2006 02:04 GMT
Jeff -

It goes something like this:

Sub ChartOnEveryWorksheet()
 Dim ws As Worksheet
 Dim cht As Chart

 For Each ws In ActiveWorkbook.Worksheets
   Set cht = ws.ChartObjects.Add(100,100,350,275).Chart
   ' adjust arguments above to get preferred chart position in sheet
   cht.ChartType = xlXYScatter
   ' adapt to your preferred chart type
   With cht.NewSeries
     .Name = "Whatever"
     .XValues = ws.Range("B1:B100")
     .Values = ws.Range("D1:D100")
     ' Adjust ranges as required
   End With
 Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______

> Hi i want to plot the graph for every worksheet (column B and column
> D). I have more than 50 worksheets in the same workbook. How do i write
> a macro to ask the excel to plot the graph for every sheet and present
> the chart object on the same sheet? thank you very much for your help!
> i have been working on this over 2 days still cannot figure it out...
jeftiong - 24 Aug 2006 17:26 GMT
Hi Jon,

there is a an error on this line of code

   ActiveChart.SetSourceData
Source:=Sheets("myworkbooks").Range("A5,C10" _
       ), PlotBy:=xlColumns

this is not the first time, i tried to write the code myself, but
everytime my laptop has this error

"Runtime error '9', subscript out of range"

you know how to solve this? this has been bugging me for past few
days!!

thanks!!!

> Jeff -
>
[quoted text clipped - 30 lines]
> > the chart object on the same sheet? thank you very much for your help!
> > i have been working on this over 2 days still cannot figure it out...
Andy Pope - 24 Aug 2006 19:26 GMT
Hi,

Do you have a worksheet called myworkbooks?

Cheers
Andy

> Hi Jon,
>
[quoted text clipped - 48 lines]
>>>the chart object on the same sheet? thank you very much for your help!
>>>i have been working on this over 2 days still cannot figure it out...

Signature

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.