selecting data

royboy531

Board Regular
Joined
Nov 11, 2005
Messages
52
I have a monthly file will numerous entries on each date. I am trying to create a macro that will create new monthly file instead of doing it by hand. As it is now I have to copy so many rows from the old file into the new file to get it started. I am looking for a code that will copy 74 rows or one entry prior to the beginning of the month, whichever is more. example- if I have 100 entries from 12/1/05 on then I want to select all entries from Dec. plus one row from Nov. If I only have 50 rows starting at 12/1/05 then it will select 74 rows from the most recent back into Nov. (however far it needs to go). I think I have a code to just select the 74 rows but I'm not sure how to modify it how I want. Here is the code that I have-

Code:
Range(Range("A1").End(xlDown), Range("A1").End(xlDown).Offset(-74, 0)).EntireRow.Copy
I hope I made this clear????

thanks
royboy531
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi

This assumes that there will be an entry for the last day of the relevant month, and the data

Code:
Sub bbb()
 lastrow = Cells(Rows.Count, "A").End(xlUp).Row
 startrow = WorksheetFunction.Match(Evaluate("=eomonth(" & Cells(lastrow, "A").Address & ",-2)"), Range("a:a"), 0)
 Range(Cells(startrow, "A"), Cells(lastrow, "A")).Select
End Sub

Tony
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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