Convert monthly and annual data into columns

jbcrut01

New Member
Joined
Aug 7, 2011
Messages
1
I have data arranged as follows:

Jan Feb Mar Apr May etc
2011 999 99 99 99 99
2010 99 99 99 99 99
2009
etc

I want to convert this into a two columns: (1) column registering the month and year and (2) a column with the data. How do I make this happen?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
for checking purposes I h ave the changed the data. sample data in sheet 1 is like this

Excel Workbook
ABCDEF
1JanFebMarAprMay
2201112345
32010678910
Sheet1


now run this macro test and see sheet2

Code:
Sub test()
Dim rrow As Range, rcol As Range, crow As Range, ccol As Range, result As Range
Worksheets("sheet1").Activate
Set rrow = Range(Range("B1"), Range("B1").End(xlToRight))
Set rcol = Range(Range("A2"), Range("A2").End(xlDown))
For Each crow In rrow
For Each ccol In rcol
With Worksheets("sheet2")
Set result = .Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End With
result = crow & " " & ccol
result.Offset(0, ccol.Column) = Intersect(Columns(crow.Column), Rows(ccol.Row))
 Next ccol
Next crow
End Sub

Code:
Sub undo()
Worksheets("sheet2").Cells.Clear
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,898
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top