?
Solved

Script a Chart in Microsoft Office Excel 2007 pro SP1

Posted on 2008-06-13
5
Medium Priority
?
486 Views
Last Modified: 2011-10-19
I am trying to figure out how to script an Excel chart.  I should be able to script a spreadsheet that looks like the attached file "Spreadsheet-without-Chart.xls" by using Log Parser (I'm halfway to figuring that out).  I would like to automatically add a chart so the spreadsheet looks like "Spreadsheet-with-Chart.xls".  I have a tab for every 50+ servers that we generate stats on so it is time-consuming to create the chart for each one.  Does anyone have any ideas?
Spreadsheet-with-Chart.xls
Spreadsheet-without-Chart.xls
0
Comment
Question by:Mark_A_Denham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
CSLARSEN earned 1000 total points
ID: 21792414
Suggestion
Make a chart sheet, make the reference to the "datasheets" dynamic

Name a range: CurServer
Enter the name of a sheet in that cell
reference the data in to a the range used for the chart via an indirect function exploiting the named range "Curserver"

You should be able to get the chart data by entering the name of the tab in curserver
e.g. for a dynamic reference til cell C8 it would be
=INDIRECT("'"&CurServer&"'!C8")

Cheers
cslarsen
0
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 21792420
sorry poor semantics "...a chart sheet" should be understood as a sheet with the chart in. More or less like you have it now.
Cheers
cslarsen
0
 
LVL 6

Assisted Solution

by:Jaffa0
Jaffa0 earned 1000 total points
ID: 21792889
I think a dynamic chart is a much better idea. That bing said, this should create the processor charts. You can adapt it to do the same thing for memory, change the colours etc.
Sub CreateCharts()
 
Dim chaChart1 As Chart
Dim shtCurr As Worksheet
 
 
    For Each shtCurr In ThisWorkbook.Worksheets
        shtCurr.Activate
        shtCurr.Shapes.AddChart(xlAreaStacked100, 3.75, 395.25, 372.75, 201.75).Select
        Set chaChart1 = ActiveChart
        With chaChart1
        .ChartType = xlAreaStacked100
        
        For a = 0 To 4
            .SeriesCollection.NewSeries
            .SeriesCollection(a + 1).Name = "=" & shtCurr.Name & "!" & shtCurr.[$E$2].Offset(a, 0).Address
            .SeriesCollection(a + 1).Values = "=" & shtCurr.Name & "!" & shtCurr.[$C$2].Offset(a, 0).Address & "," & shtCurr.Name & "!" & shtCurr.[$C$8].Offset(a, 0).Address & "," & shtCurr.Name & "!" & shtCurr.[$C$14].Offset(a, 0).Address & "," & shtCurr.Name & "!" & shtCurr.[$C$20].Offset(a, 0).Address & "," & shtCurr.Name & "!" & shtCurr.[$C$26].Offset(a, 0).Address
            .SeriesCollection(a + 1).XValues = "={""Mon"",""Tue"",""Wed"",""Thu"",""Fri""}"
        Next a
        .SetElement (msoElementChartTitleAboveChart)
        .ChartTitle.Text = shtCurr.Name & " Processor"
        End With
    Next shtCurr
        
End Sub

Open in new window

0
 

Author Comment

by:Mark_A_Denham
ID: 21806992
Thanks everyone - I'll try your script Jaffa0 as soon as I finish automating the rest of the spreadsheet.  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question