0

Excel または PowerPoint の積み上げ棒グラフで #N/As をグラフ化しないようにするにはどうすればよいですか? このようなデータがあります

日付 売上高

2012 年 1 月 1.5 .5

2012 年 2 月 2.6 1.5

該当なし #該当なし #該当なし

該当なし #該当なし #該当なし

N?A はある時点でデータを取得する可能性があるため、データの範囲内にあり、動的です。オフセットは、Powerpoint で作成したグラフではうまく機能しないため、使用したくありません。125 枚以上のスライドと 100 枚以上の図表があるため、手動での変更はよくありません。Powerpoint でグラフを作成し、グラフの背後にあるデータ ページへのリンクを追加しています。更新は問題ありませんが、これらのリンクをすべて解除した後 (これにはマクロがあります)、数式にはシート名 (Sheet1 など) が必要なため、範囲という名前のオフセットは更新されませんが、Powerpoint はそれを「Microsoft PowerPoint のグラフ」と呼びます。 .

これを十分に説明したことを願っています。ありがとう

4

1 に答える 1

0

オフセットや名前付き範囲をうまく使用できないため、この PPT マクロを作成して、データのデータ範囲をリセットしました。 /A 2) データ シートの F1 では、countif not = 0 を使用して、チャートの行数をカウントする必要があります 3) チャートに名前を付けます。StackedBar1 実行マクロを使用しました

誰かがより簡単な解決策を持っている場合は、私に知らせてください。

Sub C_SetSourceData_StackedBar()
Dim s As Slide
Dim shp As Shape

For Each s In ActivePresentation.Slides   'moves through all slides in presentation
For Each shp In s.Shapes                  'moves through each shape on slide
    If shp.Name = "StackedBar1" Then      ' stacked bar chart that needs source data updated is named this

        Set c = shp.Chart                 'set c to the chart object

        Dim data As ChartData
        Set data = c.ChartData             'sets data to the chartdata behind the chart
        data.Activate                       'need to activate the chartdat(excel sheet)

            'in cell F1 the formula =countif(A1:A50,"<>0")  this counts the rows that are not zero
        x = data.Workbook.Worksheets(1).Range("F1").Value  'gets the last row number of data not zero
        Let rng = "Sheet1!$A$1:$E$" & x                    ' creates the source range as a string

       c.SetSourceData (rng)                               ' Sets the new source data range

        data.Workbook.Close                                 ' Close the chartdata workbook
    End If
Next shp
Next s
End Sub
于 2012-12-05T18:04:01.603 に答える