Excel Waterfall Charts:无法在VBA生成的瀑布图中调整图/图例区域的大小

问题描述

我在Excel(办公室365 ProPlus)中具有VBA功能,可生成瀑布图,请参见下面的示例。生成它们之后,我想调整绘图/图例/轴区域的大小,只是为了调整外观。

但是Excel不允许我这样做;该区域的边缘似乎是固定的(请参见蓝色圆点/圆圈),我无法抓住它们。 我可以更改轴范围,但不能更改区域大小。如果我更改图表类型,例如到堆积的酒吧都行得通。

此工作表不受保护。

这是一个已知问题吗?

解决方法吗?

我的代码中(下面)是否有某些东西会导致这种行为,或者缺少某些东西?

2 waterfall charts - plot area

    Dim rngChartValues          As Range
    Dim rngChartXValues         As Range
    Dim myChart                 As Chart
    Dim myShape                 As Shape
    Dim dStartValue             As Double
    Dim dEndValue               As Double
    Dim dDeltaSurplus           As Double
    Dim dDeltaPC                As Double
    Dim chartTitle              As String
    Dim rngToplace              As Range

    rngChartValues.Select
    Set myShape = ActiveSheet.Shapes.AddChart2(395,xlWaterfall)
    Set myChart = myShape.Chart 'ActiveChart
    
    Application.CutcopyMode = False
    rngToplace.Select
    
    With myShape
        .Left = rngToplace.Left
        .Top = rngToplace.Top
        .Placement = xlFreeFloating
        .Height = 450
    End With
    
    With myChart
        .Legend.Delete
        .chartTitle.Text = chartTitle
        .SeriesCollection.NewSeries
        .Parent.name = chartTitle
        With .FullSeriesCollection(1)
            
            .name = chartTitle
            .Values = rngChartValues
            .XValues = rngChartXValues
            
            dStartValue = shtCharts.Cells(rowCapSurplusEarlr,colCA).Value
            dEndValue = shtCharts.Cells(rowCapSurplusLater,colCA).Value
            dDeltaSurplus = shtCharts.Cells(rowDeltaSurplus,colCA).Value
            dDeltaPC = Abs(dDeltaSurplus / dStartValue)
            
            ' handle the last bar as total bar
            With .Points(.Points.Count)
                .IsTotal = True
                If dDeltaPC < 0.1 Then                                          ' change is smaller than 10%
                    If dDeltaSurplus < 0 Then                                   ' ...but still negative
                        .Format.Fill.ForeColor.RGB = RGB(255,204,0)           '   => light orange
                    Else                                                        ' ... and positive
                        If dEndValue < 0 Then                                   '   ... but the surplus is till negative
                            .Format.Fill.ForeColor.RGB = RGB(255,0)       '       => light orange
                        Else                                                    ' ... and the surplus is positive
                            .Format.Fill.ForeColor.RGB = RGB(153,0)       '   => light green
                        End If
                    End If
                ElseIf dDeltaSurplus < 0 Then                                   ' change is >10% and negative
                    .Format.Fill.ForeColor.RGB = RGB(255,153,0)               '   => orange
                Else                                                            ' cange is >10$ and positive
                    If dEndValue < 0 Then                                       ' ... but the surplus is till negative
                        .Format.Fill.ForeColor.RGB = RGB(255,255,0)           '   => yellow
                    Else                                                        ' ... and the surplus is positive
                        .Format.Fill.ForeColor.RGB = RGB(0,160,0)             '   => green
                    End If
                End If
                
            End With
        End With
    End With
    
    With myChart.Parent
        intTmp = .Width
        intTmp = .Height
    End With

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)