したがって、各年の各月の最高価格と最低価格を見つける必要があります。
Sub Anaylze()
Dim datemonthcount As Long
Dim dateyearcount As Long
Dim yearcount As Long
Dim month As Long
Dim yearstart As Long
Dim maxprice As Long
Dim minprice As Long
Dim rowprice As Long
Dim percentchange
Dim counterlong As Integer
rowprice = 1
yearstart = 2002
counterlong = 0
Range("A1").Select
Do Until IsEmpty(ActiveCell) Or ActiveCell.Value = 0 Or IsNumeric(ActiveCell) = False
counterlong = counterlong + 1 'Increments the counter
If year(ActiveCell.Text) <> year((ActiveCell.Offset(-1, 0).Text)) Then
dateyearcount = dateyearcount + 1
End If
ActiveCell.Offset(1, 0).Select ' Step down 1 row from present location.
Loop
For yearcount = 0 To dateyearcount
For month = 1 To 12
'Range("A1", "B" & counterlong).AutoFilter Field:=1, Criteria1:=">=" & month & "/01/" & yearstart, Operator:=xlAnd, Criteria2:="<=" & month & "/31/" & yearstart
maxprice = WorksheetFunction.Max(Range("A1", "B" & counterlong).AutoFilter(Field:=1, Criteria1:=">=" & month & "/01/" & yearstart, Operator:=xlAnd, Criteria2:="<=" & month & "/31/" & yearstart))
minprice = WorksheetFunction.Min(Range("A1", "B" & counterlong).AutoFilter(Field:=1, Criteria1:=">=" & month & "/01/" & yearstart, Operator:=xlAnd, Criteria2:="<=" & month & "/31/" & yearstart))
Cells(rowprice, "g") = maxprice
Cells(rowprice, "h") = minprice
rowprice = rowprice + 1
Next
yearstart = yearstart + yearcount
Next
End Sub
私の最大の問題は、フィルターを機能させることです。私のデータはこのようにフォーマットされています
2012年10月26日61.66 2012年10月25日61.6