# Creating a time series from data grouped in months for multiple years

1. ## Creating a time series from data grouped in months for multiple years

Hello Excel_lent community!

I need to create a time series out of data that are grouped by month for many years. These are data for rainfall events. I am attaching an Excel file that will explain everything. The code that I have worked out thus far is also included but it is not doing what I want. Any help is appreciated !  Register To Reply

2. ## Re: Creating a time series from data grouped in months for multiple years

Private Sub CommandButton1_Click()
Dim sim As Double, j As Double, m As Double
Dim year As Double, column As Double
Dim month As Double, row As Double, ss As Double
sim = Cells(1, 1) ' count values
m = 60 ' starting row from where the code outputs the value
row = 1
column = 2
For year = 2038 To 2070 ' number of years
For month = 1 To 12 ' number of months
For i = 1 To sim

If Cells(row, column) = year Then

For j = 1 To 24
Cells(m, 1) = Cells(row + 1, column) + ((j - 1) * 0.0104444444444)
Cells(m, 2) = Cells(j + 2, column)

m = m + 1
Next j
column = column + 1

Else
column = column + 1
End If

Next i

row = row + 26
sim = Cells(row, 1)
column = 2

Next month

row = 1
sim = Cells(row, 1)
column = 2

Next year

End Sub  Register To Reply

There are currently 1 users browsing this thread. (0 members and 1 guests) 