1

Data is in one column and I need to have it in a matrix.

So my data is like this:
data

But I need it to be like this:
correct format

And the code I have so far is:

Sub Macro1()    
    Sheets("Sheet4").Select
    Range("A2:C2").Select
    Selection.AutoFilter
    ''' For January

    ActiveSheet.Range("$A$2:$C$12056").AutoFilter Field:=1, Operator:= _
        xlFilterValues, Criteria2:=Array(1, "1/31/1984")
    'Copy
    Range("B2").Select
    ActiveCell.Offset(1, 0).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy

    Sheets("Sheet2").Select
    Range("C1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Select

    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

It works, but of course I need the loop to change the years to go from 1984 to 2018 and within that loop to go from 1 to 12.

ActiveSheet.Range("$A$2:$C$12056").AutoFilter Field:=1, Operator:= _
    xlFilterValues, Criteria2:=Array(1, "**1/31/1984**")
Community
  • 1
  • 1
  • 1
    I recommend to have a look at PivotTables (which should be a easy solution for your question). And I recommend to read [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) if you go ahead coding VBA. – Pᴇʜ Nov 05 '18 at 08:19

0 Answers0