Copy row base on date, paste to another sheet by month

jimayers

Board Regular
Joined
Nov 14, 2010
Messages
99
I am trying to copy a row of information based on a date in column "H" in sheet 1, then paste/insert that row into the month specific section in sheet 2. Sheet 2 has 12 sections for the 12 months. So on sheet 2, range("H1: H8") is a header, with a big "January" in "H4" where every row below is pasted data from sheet 1 for January. AND so on!

I loop using
For y = 5 to Lastrow
....For counterx = 1 to 12
I am attempting to loop 12 times in every row of data in sheet 1 checking for one of the 12 months, then copying the row into sheet 2
I have been trying to use month() and /or monthname() with no success.

Anyhelp would be appreciated.
Thanks - Jim
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Here is an example of how I would do it.

Code:
Dim c As Range, i As Long
For i = 1 To 12
    With Sheets("Sheet1")
        For Each c In .Range("H5", .Cells(Rows.Count, 8).End(xlUp))
            If Month(c.Value) = i Then
                Select Case i
                    Case 1
                        'copy paste to January
                    Case 2
                        'copy paste to February
                    'on through Case 12
                End Select
            End If
        Next
    End With
Next
 
Upvote 0
Thank you...that worked. Although the code was a lot longer than excpected as I needed to write the copy/paste code for each of the 12 cases.
But I'm up and running now - yahoo!:)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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