VBA Code:
' VBA Code to Create a Scatter Plot Chart in Excel
' This code creates a scatter plot chart based on specified data range
Sub CreateScatterPlotChart()
Dim ws As Worksheet
Dim rngData As Range
Dim cht As ChartObject
' Set the worksheet object
Set ws = ThisWorkbook.Worksheets("Sheet1") ' Replace "Sheet1" with your sheet name
' Set the range of data for the chart
Set rngData = ws.Range("A1:B10") ' Replace with your data range
' Create a new chart object on the worksheet
Set cht = ws.ChartObjects.Add(Left:=100, Width:=400, Top:=100, Height:=300)
' Set the source data for the chart
cht.Chart.SetSourceData rngData
' Set the chart type to scatter plot
cht.Chart.ChartType = xlXYScatter
' Optional: Customize chart properties, such as titles, axis labels, etc.
' cht.Chart.HasTitle = True
' cht.Chart.ChartTitle.Text = "Scatter Plot Chart"
' cht.Chart.Axes(xlCategory).HasTitle = True
' cht.Chart.Axes(xlCategory).AxisTitle.Text = "X Values"
' cht.Chart.Axes(xlValue).HasTitle = True
' cht.Chart.Axes(xlValue).AxisTitle.Text = "Y Values"
End Sub