如何在Excel图表中显示隐藏的行,但不隐藏的列?

有没有办法让Excel图表在隐藏的行中绘制数据,但不是在隐藏的列中? 我已经知道如何使用“select数据”选项,右键单击图表时,转到“隐藏和空单元格”选项,该选项提供了“以隐藏行和列显示数据”选项。 然而,我无法find一种方式来显示隐藏的行中的数据,而不显示隐藏的列中的数据,并希望有人能够提出一个VBA解决scheme。

非常感谢,

杰夫

我只是把这个鼓起来给你 作为一个警告,使用图表可能非常棘手。 此代码仅适用于特定types的图表,您可能需要进行一些调整才能使用特定的数据集。

 Option Explicit Sub RemoveHiddenColumns() Dim myChart As ChartObject Set myChart = ActiveSheet.ChartObjects("Chart 1") 'place in here whichever chart you need to reference, asssumes the chart is on the activesheet myChart.Activate 'first activate the chart Dim i As Integer For i = 1 To ActiveChart.SeriesCollection.Count 'loop through each series Dim strText As String, strCol As String, strSht As String, intCol As Integer strText = Split(ActiveChart.SeriesCollection(i).Formula, ",")(2) 'extract sheet name and column of series strSht = Split(strText, "!")(0) 'get sheet name of series strCol = Split(strText, "!")(1) 'get column range of series Dim wks As Worksheet Set wks = Worksheets(strSht) If wks.Range(strCol).EntireColumn.Hidden = True Then 'if the column is hidden ActiveChart.SeriesCollection(i).Delete 'remove the series End If Next End Sub