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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 

jimayers

Board Regular
Joined
Nov 14, 2010
Messages
99
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:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,592
Messages
5,832,630
Members
430,149
Latest member
amitk1

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
Top