Copy rows and columns for a specific month

SimondsJM

New Member
Joined
Apr 16, 2011
Messages
30
I have a sheet with data that is dated, I would like to copy data from that sheet to a separate sheet for each month. This way I have a Main sheet and 12 separate ones for each month.

I was thinking about doing something in VB to copy the data but don't know how to tell it that if the date is in this month move to this sheet.

So the data is on the sheet "Master List"
All my month sheets are named : Jan, Feb, March, April, May, June, July, August, Sept, Oct, Nov, Dec

The data is on columns B (the Date), C, D, & E that all need to be copied and pasted to the corresponding month.

Any help is greatly appreciated.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
ok so does this work?

Code:
Sub MasterList()
Dim LR As Long, i As Long, iMonth As Long, ALR As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
iMonth = Month(Cells(i, 2))
Select Case iMonth
    Case 1
        ALR = Sheets("Jan").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Jan").Range("A" & ALR)
    Case 2
        ALR = Sheets("Feb").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Feb").Range("A" & ALR)
    Case 3
        ALR = Sheets("March").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("March").Range("A" & ALR)
    Case 4
        ALR = Sheets("April").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("April").Range("A" & ALR)
    Case 5
        ALR = Sheets("May").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("May").Range("A" & ALR)
    Case 6
        ALR = Sheets("June").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("June").Range("A" & ALR)
    Case 7
        ALR = Sheets("July").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("July").Range("A" & ALR)
    Case 8
        ALR = Sheets("August").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("August").Range("A" & ALR)
    Case 9
        ALR = Sheets("Sept").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Sept").Range("A" & ALR)
    Case 10
        ALR = Sheets("Oct").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Oct").Range("A" & ALR)
    Case 11
        ALR = Sheets("Nov").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Nov").Range("A" & ALR)
    Case 12
        ALR = Sheets("Dec").Range("A" & Rows.Count).End(xlUp).Row + 1
        Range(Cells(i, "B"), Cells(i, "E")).Copy Destination:=Sheets("Dec").Range("A" & ALR)
    End Select
Next i
End Sub
 
Upvote 0
This looks good, just not sure where to put the code, also i need Columns B,C,D,E to be copied to the date sheets, i dont see C, &D on here
 
Upvote 0
The code uses the range from B to E
this code would be put into the vba module, press Alt + F11, insert module. Then copy the code from here and paste into that white space. Press Alt + Q to close VBA window. The macro can then be selected from the Macro dialog window, Alt + F8
 
Upvote 0
I just put it in and tried it but i don't see the data moving over. I forgot to put in that the data start on Row 6, Row 5 being the headers. Will be the same on all the Month sheets as well.
 
Upvote 0
and the dates are true dates? What happens when you try this in an empty cell
=isnumber(B6)
 
Upvote 0
It says True

the dates are generated by a form, using a calendar to select the date and put in textbox, then put that date onto the sheet from a command button.

Date: 5/25/2011 for example
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,702
Members
452,938
Latest member
babeneker

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