確かにデータ要素にラベルを付ける機能が無い…※最新のExcelのバージョンでは簡単にできるようですね。
検索してみた
検索すると、MSのサポートにそのやり方が…Macでもできるかな?
ExcelのMac版でも出来るのかな〜とやってみたら、簡単にできました。1)まずはデータから。平成1年〜3年にかけて、AとBがこのように変化しているという感じのデータ。
2)これを選択しておいて「挿入」−「グラフ」「散布図」。
3)「開発」−「エディタ」で、VBAエディタを開いてから、「挿入」−「標準モジュール」で立ち上がった画面に下記のプログラムをコピペ。
Sub AttachLabelsToPoints()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
' Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(1).Formula
'Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _
Mid(Left(xVals, InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(1).Points(Counter).HasDataLabel = _
True
ActiveChart.SeriesCollection(1).Points(Counter).DataLabel.Text = _
Range(xVals).Cells(Counter, 1).Offset(0, -1).Value
Next Counter
End Sub
4)Excelに戻り、先ほどのグラフを選択したまま「開発」−「マクロ」、そして「AttachLabelsToPoints」を選択すると、データ要素にラベルが付加されます。
こうすると、「平成1年から3年にかけて、このように数値が動いているのね〜」ということが分かります。







0 件のコメント:
コメントを投稿