Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 6 of 6

Thread: Use of MS Chart Control in VBA Form

  1. #1
    Join Date
    12th May 2006
    Posts
    3

    Use of MS Chart Control in VBA Form

    I am trying to use the Chartspace object on a VBA form in Excel 2002, but am unable to find out how to specify the speadsheet data to be used for each series.

    I have found out how to add series, and to add titles & legend etc. but can anybody help with the actual data.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: Use of MS Chart Control in VBA Form

    Can you post and example of what you have so far?

    Cheers
    Andy


  3. #3
    Join Date
    12th May 2006
    Posts
    3

    Re: Use of MS Chart Control in VBA Form

    This is the code that I have so far - it adds a chart to the chartspace on the form along with title and axis labels. It also sets the colour of series(0) in the legend, but no values are displayed.

    Sub AddChart()
    ChartSpace1.Charts.Add
    ChartSpace1.Charts(0).Type = chChartTypeColumnClustered
    ChartSpace1.Charts(0).HasTitle = True
    ChartSpace1.Charts(0).HasLegend = True
    ChartSpace1.Charts(0).Title.Caption = "Test Chart"
    ChartSpace1.Charts(0).SeriesCollection.Add
    ChartSpace1.Charts(0).Legend.Position = chLegendPositionTop
    ChartSpace1.Charts(0).SeriesCollection(0).Type = chChartTypeColumnClustered
    ChartSpace1.Charts(0).SeriesCollection(0).Interior.Color = vbRed
    ChartSpace1.Charts(0).SeriesCollection(0).Type = chChartTypeColumnClustered
    ChartSpace1.Charts(0).Axes(1).HasTitle = True
    ChartSpace1.Charts(0).Axes(1).Title.Caption = "Time"
    ChartSpace1.Charts(0).Axes(1).MajorTickMarks = True
    ChartSpace1.Charts(0).Axes(0).HasTitle = True
    ChartSpace1.Charts(0).Axes(0).Title.Caption = "Rate"
    End Sub

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: Use of MS Chart Control in VBA Form

    What is ChartSpace1 ?

    Cheers
    Andy


  5. #5
    Join Date
    12th May 2006
    Posts
    3

    Re: Use of MS Chart Control in VBA Form

    Chartspace1 is the name of the MS Office 9 Chart object that I added to the form. I have now found how to add values from an array, which I can populate from the speadsheet. I'm not sure if it is possible to reference the data directly to the spreadsheet, but for now I have a solution.

    Thanks

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: Use of MS Chart Control in VBA Form

    The help is fairly helpful
    VB:
    This example creates a chart that Is bound To a spreadsheet. The series name Is In cell B1, the category names are In cells A2:A28, And the values are In cells B2:B28. 
     
    Set c = ChartSpace1.Constants 
    Set ChartSpace1.DataSource = Spreadsheet1 
    ChartSpace1.Charts.Add 
    ChartSpace1.Charts(0).Type = c.chChartTypeLineMarkers 
    ChartSpace1.Charts(0).SetData c.chDimSeriesNames, 0, "b1" 
    ChartSpace1.Charts(0).SetData c.chDimCategories, 0, "a2:a28" 
    ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimValues, 0, "b2:b28" 
    
    

    Cheers
    Andy


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Identifying selected control in infopath form control in a windows application
    By Dave Hawley in forum Office 2007 Migration and Application Compatibility
    Replies: 0
    Last Post: May 10th, 2009, 04:32
  2. Replies: 5
    Last Post: April 15th, 2006, 02:15
  3. form control options
    By excel_for_fun in forum EXCEL HELP
    Replies: 1
    Last Post: March 7th, 2005, 17:55
  4. Possible to retrieve other form control values
    By HELPHELPTHANXS in forum Excel and/or Access Help
    Replies: 3
    Last Post: October 27th, 2004, 19:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno