Hi everyone. I could really use some help getting the following code to work. In my spreadsheet budget data is displayed horizontally by month.
Oct-10 Nov-10
2000 500
2345 1111
1233
I need it to be displayed vertically with the month next to each expense.
Oct-10 2000
Oct-10 2345
Oct-10 1233
Nov-10 500
Nov-10 1111
When I run the following code it seems to copy the first month of data multiple times instead of copying the first month down, and then moving to the next month and copying it below it.
I also run into Error '1004' to do with copying and/or pasting.
Cheers!
Oct-10 Nov-10
2000 500
2345 1111
1233
I need it to be displayed vertically with the month next to each expense.
Oct-10 2000
Oct-10 2345
Oct-10 1233
Nov-10 500
Nov-10 1111
When I run the following code it seems to copy the first month of data multiple times instead of copying the first month down, and then moving to the next month and copying it below it.
I also run into Error '1004' to do with copying and/or pasting.
Code:
Sub CopyMonthlyBudgetDown()
Dim Y As Integer
Dim w As Long
Dim B As Long
Dim n As Long
'This gives me how many columns of data need to be copied
Let Y = Worksheets("APExport").Range("A1:ZZ1").Cells.SpecialCells(xlCellTypeConstants).Count
Do Until B = Y
'The first expense is at (2,5)
B = 5
n = 2
'This finds the cell where the expenses should be pasted
Sheets("APExport").Range("D1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
c = ActiveCell.Address
'This selects the expenses to be copied
Sheets("APExport").Cells(n, B).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
B = B + 1
Loop
End Sub
Cheers!