2 Lists but different time frames.

G

gaga.kaplan

Hi everyone,
I the following data:

GDP for each quarter so
1981q1 5,307.5
1981q2 5,266.1
1981q3 5,329.8
1981q4 5,263.4
1982q1 5,177.1
1982q2 5,204.9
1982q3 5,185.2
1982q4 5,189.8
1983q1 5,253.8
1983q2 5,372.3
1983q3 5,478.4
1983q4 5,590.5.....
This continues until 2007
................................
What I want to do is to transform each quarter into monthly values
this into
AJan-1981 5,307.5
Feb-1981 5,307.5
Mar-1981 5,307.5
Apr-1981 5,266.1
May-1981 5,266.1
Jun-1981 5,266.1
Jul-1981 5,329.8
Aug-1981 5,329.8
Sep-1981 5,329.8
Oct-1981 5,263.4
Nov-1981 5,263.4
Dec-1981 5,263.4
Jan-1982 5,177.1
Feb-1982 5,177.1
Mar-1982 5,177.1

*data continues until 2007, so manually inputting it would not be
feasible.

The problem I have is that I can't figure out a code that will copy
the monthly value three times and then move 1 step down and copy the
next quarter...

Any help?
 
J

Joel

Sub monthlyReport()

RowCount = 1
Do While Range("A" & RowCount) <> ""
Monthlyvalue = Range("B" & RowCount)
MyYear = Val(Left(Range("A" & RowCount), 4))
MyMonth = 3 * Val(Right(Range("A" & RowCount), 1))
MyDate = DateSerial(MyYear, MyMonth, 1)
Range("A" & RowCount) = MyDate
Rows((RowCount + 1) & ":" & (RowCount + 2)).Insert
MyDate = DateSerial(MyYear, MyMonth + 1, 1)
Range("A" & (RowCount + 1)) = MyDate
MyDate = DateSerial(MyYear, MyMonth + 2, 1)
Range("A" & (RowCount + 2)) = MyDate
Range("A" & RowCount & ":A" & (RowCount + 2)).NumberFormat = "mmm-yyyy"
Range("B" & (RowCount + 1) & ":B" & (RowCount + 2)) = Monthlyvalue
RowCount = RowCount + 3
Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top