Adding Data Labels to scatter graph in PowerPoint?

airplay

New Member
Joined
Jun 14, 2010
Messages
9
Hi,

I'm trying to automatically chart a scatter graph in PowerPoint using a dataholder in Excel (i.e. a template where the user enters the data for the chart).

I then need to add data labels to each series collection - so instead of each data point showing the Y axis score or 'Series 1' it shows the name of the data point - i.e. 'Monday', 'Tuesday', etc.

The SeriesCollection property doesn't seem to work in PowerPoint...and I'm at a lost.

Here is my current code - note that the SetSourceData doesn't set the right data columns and I have to go in and press 'Switch Columns' to get it to chart properly.

Code:
Sub CreateAutomatedChart()
'********************
'*      SETUP       *
'********************
Dim xlApp As Object 'Sets Excel as Object
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
Dim xlWks As Object 'Set Excel dataholder as Object
    file = ActivePresentation.Path & "\Automated Charts - Service Area Awareness Summary.xlsx"
    Set xlWks = xlApp.Workbooks.Open(file)
'********************
'*   UPDATE CHART   *
'********************
Set scatterChart = ActivePresentation.Slides(1).Shapes(2).Chart
    scatterChart.ChartData.Activate
    For x = 2 To 32
        scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 1).Value = _
            xlWks.Sheets(1).Cells(x, 2)                                     'X Axis
        
        scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 2).Value = _
            Format(xlWks.Sheets(1).Cells(x, 3), "0")                        'Y Axis
            
        scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 3).Value = _
            xlWks.Sheets(1).Cells(x, 1)                                     'Labels
    Next x
scatterChart.SetSourceData ("Sheet1!$A$2:$B$" & x)
scatterChart.ChartData.Workbook.Close
FileName = "Service Area Awareness Summary - " & Format(Date, "yy mm dd")
ActivePresentation.SaveAs FileName:=ActivePresentation.Path & "\" & FileName
End Sub

Any help would be very greatly appreciated! I'm at a complete lost here... :eeek:

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,225,537
Messages
6,185,513
Members
453,298
Latest member
Adam1258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top