LoginSignup
0
0

More than 5 years have passed since last update.

Tips01:エクセルでデータ分析【VBA】

Posted at

エクセルでデータ分析

Excelのグラフはy軸は2軸までしか対応しておらず、複数のグラフを並べて表示することが多いかと思います。
特に、時系列データ分析では、同じカラムの別時間帯のデータが欲しい場合が多いので下記のモジュールを作成しました。

コード

Start,Endにセルを絶対参照で指定してやることで、すべてのグラフの参照個所を変更することができます。
replaceを用いることですべての文字列を置き換えることになりますが、これの応用でタイトルやy軸名称など一括で変更することができます。

Macro

Function Macro()
'===============================================================
'アクティブシートに存在するすべてのグラフの文字列を入れ替える。
'===============================================================

Dim cht As ChartObject
Dim ser As Series

Dim sCell1 As String
Dim eCell1 As String
Dim sCell2 As String
Dim eCell2 As String

Dim srcData As String

'----------------------------
'初期設定
'----------------------------
sCell1 = "$65"
eCell1 = "$1447"
sCell2 = "$68"
eCell2 = "$12967"

For Each cht In ActiveSheet.ChartObjects
    For Each ser In cht.Chart.SeriesCollection
    '------------------------------------------------------------
    'Replace((変更前の数値),(変更後の数値))
    '------------------------------------------------------------
    ser.Formula = Replace(ser.Formula, sCell1, sCell2)
    Next
Next

End Function

まとめ

データ分析にエクセルを使用するには限界がある。いや、ほんともう限界。
グラフ化はまだいい。でも、データの前処理はもう無理。
汎用ソフトウェアの限界だろうか。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0