時系列データの整形

Visual Basic for Applications
Sub Macro()
  Dim FirstYear As Integer
  Dim rrr As Integer
  Dim ccc As Integer
  Dim sheet As Integer
  Dim Outrrr As Integer
  Dim Outccc As Integer
  Dim cnt As Integer
  sheet = 1: rrr = 3: ccc = 3: Outrrr = 10: Outccc = 2: cnt = 0
  EndRow = Worksheets(sheet).Cells(rrr, ccc).End(xlDown).Row
  EndCol = Worksheets(sheet).Cells(rrr, ccc).End(xlToRight).Column
  FirstYear = Worksheets(sheet).Cells(rrr, ccc - 1)
  DataFrame = Range(Cells(rrr, ccc), Cells(EndRow, EndCol))
  For rrrr = rrr To EndRow
    For cccc = ccc To EndCol
      tmp = DataFrame(rrrr - (rrr - 1), cccc - (ccc - 1))
      If tmp <> "" Then
        Cells(Outrrr + cnt, Outccc) = FirstYear + rrrr - rrr & "/" & cccc - (ccc - 1) & "/1"
        Cells(Outrrr + cnt, Outccc + 1) = tmp
        cnt = cnt + 1
      Else
        Exit For
      End If
    Next cccc
  Next rrrr
  Cells(Outrrr - 1, Outccc) = "Date"
  Cells(Outrrr - 1, Outccc + 1) = "Value"
End Sub
20140818_02