タイトル | : [解決]Chartのデータ範囲を返してくれるメソッド/プロパティ |
記事No | : 12551 |
投稿日 | : 2008/06/16(Mon) 17:24 |
投稿者 | : ダンボ |
大仮説のことはいざ知らず、下記コードで汎用的な処理(複数シートの複数グラフの複数系列) ができましたので報告しておきます。
Private Sub CopyGRF(WS As Worksheet) Dim ModelSheet As Worksheet, NOC As Integer, i As Integer Set ModelSheet = ThisWorkbook.Worksheets("Model") NOC = ModelSheet.ChartObjects.Count If NOC < 1 Then Exit Sub
Application.ScreenUpdating = False For i = NOC To 1 Step -1 Call CopyGRF1(ModelSheet, WS, i) Next i Application.ScreenUpdating = True End Sub
Private Sub CopyGRF1(MD As Worksheet, WS As Worksheet, i As Integer) Dim MDChart As ChartObject, WSChart As ChartObject WS.ChartObjects(i).Delete Set MDChart = MD.ChartObjects(i) MDChart.Copy WS.Paste Set WSChart = WS.ChartObjects(i) WSChart.Left = MDChart.Left WSChart.Top = MDChart.Top Dim k As Integer With WSChart.Chart.SeriesCollection For k = 1 To .Count .Item(k).Formula = Replace(.Item(k).Formula, MD.Name, WS.Name) Next k End With End Sub
|