Chào bạn,
Chúng tôi đã tạo một mã VBA, vui lòng chèn mã đó vào một mô-đun và kiểm tra xem đó có phải là những gì bạn cần hay không:
Sub KutoolsChart()
'
' CSH
'
Dim xRg As Range
Dim i As Integer
On Error Resume Next
Set xRg = Application.InputBox(prompt:="Please select Range", Title:="Kutools for Excel", Type:=8)
If TypeName(xRg) = "Nothing" Then Exit Sub
If xRg.Columns.Count <> 3 Then
MsgBox ("Reference is not Valid")
Exit Sub
End If
ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
For i = 1 To xRg.Rows.Count
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(i).Name = xRg.Cells(i, 1).Value
ActiveChart.FullSeriesCollection(i).XValues = xRg.Cells(i, 2)
ActiveChart.FullSeriesCollection(i).Values = xRg.Cells(i, 3)
ActiveChart.FullSeriesCollection(i).ApplyDataLabels
ActiveChart.FullSeriesCollection(i).DataLabels.Select
ActiveChart.FullSeriesCollection(i).DataLabels.ShowValue = False
ActiveChart.FullSeriesCollection(i).HasLeaderLines = False
ActiveChart.FullSeriesCollection(i).DataLabels.ShowSeriesName = True
Next
End Sub
Sau khi bạn sao chép và dán mã ở trên, hãy nhấn F5 để chạy mã. Và một hộp thoại sẽ bật lên yêu cầu bạn chọn ba cột.
Nếu bạn có bất kỳ câu hỏi nào, xin vui lòng hỏi tôi.
Amanda