Hello Paul
This is very basic to plot your points and label each point with the customer name. It is only set to work with the data range that you have given(Rows 2 to 6). It uses A1 for the chart title and B1 and C1 for the axis labels. The chart is generated as a chart sheet. It will need some work to dynamically adjust to different data ranges but without knowledge of how you are gathering your data it is hard to be more general.
Sub AddChartSheet()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
Dim chtChart As Chart
' Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Create a new chart.
Set chtChart = Charts.Add
With chtChart
.Name = "CustomerSales"
.ChartType = xlXYScatter
'Link to the source data range.
.SetSourceData Source:=Sheets("Sheet1").Range("B2:C6"), _
PlotBy:=xlColumns
.HasLegend = False
.HasTitle = True
.ChartTitle.Text = "=Sheet1!A1"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Caption = "=Sheet1!B1"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Caption = "=Sheet1!C1"
End With
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(1).Formula
'Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _
Mid(Left(xVals, InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(1).Points(Counter).HasDataLabel = _
True
ActiveChart.SeriesCollection(1).Points(Counter).DataLabel.Text = _
Range(xVals).Cells(Counter, 1).Offset(0, -1).Value
Next Counter
End Sub
Regards
Harry