Vba 在没有标记线的情况下在XY散点上设置线
因此,我正在尝试使用VBA在Excel中格式化XY散点图,我希望有线连接标记,但对于标记和标记线,我希望它们不可见 出于某种原因,标记线和连接标记的线都使用相同的代码来更改其可见性特性Vba 在没有标记线的情况下在XY散点上设置线,vba,excel,Vba,Excel,因此,我正在尝试使用VBA在Excel中格式化XY散点图,我希望有线连接标记,但对于标记和标记线,我希望它们不可见 出于某种原因,标记线和连接标记的线都使用相同的代码来更改其可见性特性 chart.SeriesCollection(1).Format.Line.Visible = msoFalse 我可以使用MarkerBackGroundColor属性独立地更改颜色,但我似乎不知道如何使一个可见,而不使另一个可见 在此方面的任何帮助都将不胜感激。代码似乎很有意义。以下代码是设定点的示例 Su
chart.SeriesCollection(1).Format.Line.Visible = msoFalse
我可以使用MarkerBackGroundColor
属性独立地更改颜色,但我似乎不知道如何使一个可见,而不使另一个可见
在此方面的任何帮助都将不胜感激。代码似乎很有意义。以下代码是设定点的示例
Sub ScatterChart_setPoint()
Dim Ws As Worksheet
Dim DB As Range, myCell As Range
Dim Ch As Chart
Dim i As Integer, n As Long, r As Integer, g As Integer, b As Integer
Dim vX(), vY(), vLable(), vMarker
Dim pnt As Point
Dim Shp As Shape
Dim h As Single, w As Single, l As Single, t As Single, fs As Single
Application.DisplayAlerts = False
Set Ws = ActiveSheet 'Sheets("Current Account")
Ws.Activate
Ws.Range("a65536").Select
vMarker = Array(xlMarkerStyleCircle, xlMarkerStyleDash, xlMarkerStyleDiamond, xlMarkerStyleDot, _
xlMarkerStylePlus, xlMarkerStyleSquare, xlMarkerStyleStar, _
xlMarkerStyleTriangle, xlMarkerStyleX)
Set DB = Ws.Range("h3", Ws.Range("h3").End(xlDown)) '<~~ range of data
For Each myCell In DB
If myCell = 0 Or myCell.Offset(, 10) = "" Then
Else
n = n + 1
ReDim Preserve vX(1 To n)
ReDim Preserve vY(1 To n)
ReDim Preserve vLable(1 To n)
vX(n) = myCell
vY(n) = myCell.Offset(, 10)
vLable(n) = myCell.Offset(, -7)
End If
Next myCell
Charts.Add
With ActiveChart
.HasTitle = True
.ChartType = xlXYScatter
.Legend.Position = xlLegendPositionRight
With .ChartTitle
.Characters.Text = Ws.Range("a1").Value
.Characters.Font.Size = 12
End With
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name = "OECD"
.XValues = vX
.Values = vY
.Trendlines.Add
With .Trendlines(1)
.DisplayRSquared = True
.DisplayEquation = True
End With
End With
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = Ws.Range("r2")
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = Ws.Range("h2")
For i = 1 To n
Set pnt = .SeriesCollection(1).Points(i)
With pnt
.ApplyDataLabels
.DataLabel.Text = vLable(i)
.DataLabel.ShowValue = False
.DataLabel.ShowCategoryName = True
.MarkerStyle = vMarker(WorksheetFunction.RandBetween(0, 8))
With WorksheetFunction
r = .RandBetween(0, 240)
g = .RandBetween(0, 240)
b = .RandBetween(0, 240)
End With
.MarkerForegroundColor = RGB(r, g, b)
.MarkerBackgroundColor = RGB(r, g, b)
End With
.ApplyDataLabels
Next i
Application.DisplayAlerts = True
End Sub
子散射图_设定点()
将Ws设置为工作表
Dim DB作为范围,myCell作为范围
模糊查斯图
Dim i为整数,n为长,r为整数,g为整数,b为整数
尺寸vX(),vY(),vLable(),vMarker
变暗pnt作为点
将Shp变暗为形状
尺寸h为单个,w为单个,l为单个,t为单个,fs为单个
Application.DisplayAlerts=False
设置Ws=ActiveSheet的工作表(“活期账户”)
Ws.Activate
Ws.范围(“a65536”)。选择
vMarker=数组(xlMarkerStyleCircle、xlMarkerStyleDash、xlMarkerStyleDiamond、xlMarkerStyleDot、_
xlMarkerStylePlus、xlMarkerStyleSquare、xlMarkerStyleStar、_
xlMarkerStyleTriangle,xlMarkerStyleX)
设置DB=Ws.Range(“h3”,Ws.Range(“h3”).End(xlDown))”您可以使用
FullSeriesCollection(1).Border.LineStyle = xlNone
或
仅设置行的格式。我看不出这个答案与原始问题有什么关系。在我看来,这只是一段完整代码的复制/粘贴,做了一些不同的事情,没有任何解释。@Peh:FullSeriesCollection(1)设置更改完整标记。它需要设置。系列集合(1)。积分(i)。感谢您的回复。不幸的是,我目前正在使用Excel 2010,它不支持FullSeriesCollection对象。我相信在不久的将来,我的办公室将升级到office 365,因此在此之前我可能不得不将就一下。
FullSeriesCollection(1).Border.LineStyle = xlSolid