Need VBA code to copy entire row into monthly worksheets from a master register with same headers

boochang

New Member
Joined
Feb 22, 2017
Messages
12
Hello-

I would like a macro to copy an entire row of data, based on month of transaction.
I have identical headers from Row 1-6 and column A, on the register sheet and each month sheet (January, February, March, etc"
Data is in sheet "Register" from B7:AC500. The date for each transaction is listed in column B.
I want all transactions for the month of December moved to the "December" worksheet in the same workbook.
Starting the pasting at B7 on "December" worksheet. Once an entry is moved from the register sheet, it should only be in the December sheet. Additional December entries need to added below any entries previously moved.
Can anyone help me???
NamePeriodName0Period
EXPENSE REPORTLocationEXPENSE REPORTLocation0
Line No.DateMiles DrivenFuelAuto Rental / Tolls / Parking / TaxiAir FaresHotelPersonal & Business MealsEntertain-mentOffice SuppliesOffice & Cell Tele / InternetPostageOther $Other Describe Expense (Total AmountLine No.DateParticipantsDescriptions
112/2/2017 2 $ 1.07 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$46.07112/2/2017
212/4/2017 4 $ 2.14 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$47.14212/4/2017
312/6/2017 6 $ 3.21 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$48.21312/6/2017
412/8/2017 8 $ 4.28 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$49.28412/8/2017
512/10/2017 10 $ 5.35 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$50.35512/10/2017
612/12/2017 12 $ 6.42 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$51.42612/12/2017
712/14/2017 14 $ 7.49 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$52.49712/14/2017
85/4/2018 15 $ 8.03 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$53.0385/4/2018
912/12/2017 16 $ 8.56 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$53.56912/12/2017
1012/14/2017 17 $ 9.10 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$54.101012/14/2017
116/8/2017 18 $ 9.63 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$54.63116/8/2017
126/9/2017 19 $ 10.17 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$55.17126/9/2017
133/25/2017 20 $ 10.70 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$55.70133/25/2017
144/5/2017 21 $ 11.24 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00$56.24144/5/2017

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Well this script will copy all your data to the proper sheets assuming you already have the sheets created.
And they all have full month names like "December" "January" "May"

Now I did not have the script clear the original sheet.

Was not sure what you wanted to happen next.

Seemed like you then wanted each row of data immediately copied to proper sheet when row was created on "Register" sheet but was not sure of that.
Code:
Sub Get_Month()
Dim ans As Variant
Dim anss As Long
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Sheets("Register").Activate
Lastrow = Sheets("Register").Cells(Rows.Count, "B").End(xlUp).Row
    For i = 7 To Lastrow
        ans = Format(Cells(i, 2), "MMMM")
        anss = Sheets(ans).Cells(Rows.Count, "B").End(xlUp).Row + 1
        If anss < 7 Then anss = 7
        Rows(i).Copy Sheets(ans).Rows(anss)
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,158
Members
449,208
Latest member
emmac

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