私はあなたのためにこれを太鼓で叩きました。注意点として、グラフの操作は非常に難しい場合があります。このコードは、特定の種類のグラフでのみ機能します。特定のデータ セットを操作するには、いくつかの調整が必要になる場合があります。
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