Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA xlMarkerStyle未打印_Vba_Excel - Fatal编程技术网

Excel VBA xlMarkerStyle未打印

Excel VBA xlMarkerStyle未打印,vba,excel,Vba,Excel,以下Excel VBA模块用于根据条件更改各种线段的颜色。它工作得很好,只是它不会绘制单独的线标记。问题显然存在于xlMarkerStyleCircle、MarketSize、MarkerBackgroundColor和MarkerForegroundColor系列中。我不确定问题是否与不正确的对象命名或不正确的对象引用顺序有关。任何帮助或建议都将不胜感激。同样,如果有人看到一种更有效的方法来编码相同的目标,请随时分享 谢谢你 干杯, 约翰 这是半个答案,因为它解释了为什么您的代码没有绘制单独

以下Excel VBA模块用于根据条件更改各种线段的颜色。它工作得很好,只是它不会绘制单独的线标记。问题显然存在于xlMarkerStyleCircle、MarketSize、MarkerBackgroundColor和MarkerForegroundColor系列中。我不确定问题是否与不正确的对象命名或不正确的对象引用顺序有关。任何帮助或建议都将不胜感激。同样,如果有人看到一种更有效的方法来编码相同的目标,请随时分享

谢谢你

干杯, 约翰



这是半个答案,因为它解释了为什么您的代码没有绘制单独的行标记,但没有给出正确的方法。如果你想让我仔细看看你的问题,你必须提供你的工作表,这样我才能评估你图表的细节

另一方面,您的代码非常重复,因此效率低下

我现在讨论这两个问题

  • 对象没有
    边框
    方法。这就是原因 为什么你的代码不起作用。这意味着您不能编写类似以下内容的代码:

    .Shapes(“图表3”).CHART.SeriesCollection(1).Points(i+1).Border


    如果您想知道
    指向对象的方法,请在VBE上按F2键。如果您想了解更多有关对象和方法的信息,可以尝试或然后。同样,如果您分享您的工作表,我将能够帮助您

  • 将代码重复32次

    .Shapes(“CHART3”).Chart.SeriesCollection(1).Points(i+1)


    您可以 通过声明类型为点的变量
    p
    并赋值来避免这种情况 它的值正好位于for循环之后。我给你一个想法,你如何才能做到这一点,但为了让它正常工作,你应该分享你的工作表。

  •   Sub tropical_cyclone_track_format()
    
      With ActiveSheet
    Set r = .Range("E24:E31")
    For i = 1 To .Shapes("CHART 3").Chart.SeriesCollection(1).Points.Count - 1
    
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerStyle = xlMarkerStyleCircle
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerSize = 2
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerBackgroundColor = RGB(0, 0, 0)
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerForegroundColor = RGB(0, 0, 0)
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.LineStyle = xlContinuous
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.Color = RGB(255, 255, 64)
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Transparency = 0
      If r(i) = "1" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Weight = 1
    
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerStyle = xlMarkerStyleCircle
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerSize = 2
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerBackgroundColor = RGB(0, 0, 0)
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerForegroundColor = RGB(0, 0, 0)
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.LineStyle = xlContinuous
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.Color = RGB(255, 153, 16)
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Transparency = 0
      If r(i) = "2" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Weight = 1
    
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerStyle = xlMarkerStyleCircle
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerSize = 2
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerBackgroundColor = RGB(0, 0, 0)
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerForegroundColor = RGB(0, 0, 0)
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.LineStyle = xlContinuous
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.Color = RGB(255, 3, 0)
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Transparency = 0
      If r(i) = "3" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Weight = 1
    
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerStyle = xlMarkerStyleCircle
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerSize = 2
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerBackgroundColor = RGB(0, 0, 0)
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).MarkerForegroundColor = RGB(0, 0, 0)
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.LineStyle = xlContinuous
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Border.Color = RGB(80, 0, 0)
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Transparency = 0
      If r(i) = "4" Then .Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1).Format.Line.Weight = 1
    
      Next i
      End With
    
    End Sub
    
    Sub tropical_cyclone_track_format()
    
    Dim r As Range
    Set r = ActiveSheet.Range("E24:E31")
    
    Dim i As Integer
    For i = 1 To ActiveSheet.Shapes("CHART 3").Chart.SeriesCollection(1).Points.Count - 1
    
    Dim p As Point
    Set p = ActiveSheet.Shapes("CHART 3").Chart.SeriesCollection(1).Points(i + 1)
    
    If r(i) = "1" Then
        With p
    
            p.MarkerSize = xlMarkerStyleCircle
            p.MarkerStyle = 2
            p.MarkerBackgroundColor = RGB(0, 0, 0)
            p.MarkerForegroundColor = RGB(0, 0, 0)
            p.Format.Line.Transparency = 0
            p.Format.Line.Weight = 1
    
        End With
    End If
    
    If r(i) = "2" Then
        With p
    
            p.MarkerSize = xlMarkerStyleCircle
            p.MarkerStyle = 2
            p.MarkerBackgroundColor = RGB(0, 0, 0)
            p.MarkerForegroundColor = RGB(0, 0, 0)
            p.Format.Line.Transparency = 0
            p.Format.Line.Weight = 1
    
        End With
    End If
    
    If r(i) = "3" Then
        With p
    
            p.MarkerSize = xlMarkerStyleCircle
            p.MarkerStyle = 2
            p.MarkerBackgroundColor = RGB(0, 0, 0)
            p.MarkerForegroundColor = RGB(0, 0, 0)
            p.Format.Line.Transparency = 0
            p.Format.Line.Weight = 1
    
        End With
    End If
    
    If r(i) = "4" Then
        With p
    
            p.MarkerSize = xlMarkerStyleCircle
            p.MarkerStyle = 2
            p.MarkerBackgroundColor = RGB(0, 0, 0)
            p.MarkerForegroundColor = RGB(0, 0, 0)
            p.Format.Line.Transparency = 0
            p.Format.Line.Weight = 1
    
        End With
    End If
    Next i
    
    End Sub