Copy row from one worksheet to another based on date (Expired Date)

mandii01

New Member
Joined
Mar 21, 2011
Messages
11
Hi All,

I've been reading quite a bit and I'm not sure which is the best way to approach this whether there is an excel formula that can achieve what I want or if it will be a vba macro.

What I have: A "PROGRAM" spreadsheet that shows names of employees with their high risk work licences and when the licences are expiring.

What I need: To transfer rows that have an expired date to another sheet within the workbook - so that I can get a compressed list of who has expired licences.

So if I have John Smith with any "expired" date against his licence class his Surname, first name, licence number, expiry date and licence class would be transferred into the "EXPIRED" worksheet.

I also have conditional formatting applied.

Sorry I would post an example of the workbook but I can't seem to find the "attach" icon.

Please Help - any guidance is greatly appreciated.

Thanks again.

Mandii :)

SURNAMEFIRST NAMELICENCE NUMBERFORKLIFT TRUCK SCAFFOLDING
LF LO SB
SMITHJohn123456728/05/2016
BLOGGSJoe000306004113/01/2020 13/01/2020
WHODamienTBA18/05/202111/08/2016
SMITHETaylor000330632920/01/2020
DOEJane000317631611/05/2017 15/07/2016

<colgroup><col span="2"><col><col span="3"><col span="2"></colgroup><tbody>
</tbody>
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Please give the column number we need to do a search in for the expiration date.
Say like search column (12) for expired date.
Then tell us what columns you want copied over to the sheet named "EXPIRED"

Say like Columns "1" to columns "10" copy to sheet "EXPIRED"
 
Upvote 0
ROWColumn BColumn CColumn DColumn EColumn FColumn GColumn HColumn IColumn J
3SurnameFirst NameLicence NumberWP LicenceCN LicenceDG LicenceLF LicenceLO LicenceSB Licence
4SMITHJohn123456715/10/201630/10/201628/05/2016
5BLOGGSJoe000111222313/01/202013/01/2020
6WHODamienTBA18/05/202111/08/2016
7DOEJane999888777615/10/201911/05/201915/07/2016

<tbody>
</tbody>

Note:
  • Row & Columns are the automated "headings" in excel.
  • I have conditional formatting to highlight cells for when they are within 30 days of expiry date, 14 days of expiry date, 7 days and then due and expired.
  • I would like the second "Expired" sheet just showing the expired row details i.e. in this example those personnel on the expired sheet would be John Smith, Damien Who and Jane Doe.
  • The layout of the second "Expired" sheet would mirror the original sheet however I only want the details of those that have expired dates listed.
  • Search cells for "Expired" dates would need to be from Column E to column J
  • Copy of whole row i.e. column B - J Row 7 into second "Expired" spreadsheet.

Thanks all in advance, any help and guidance is greatly appreciated. I am thinking that there won't be an excel formula and that this may require a Vba macro.

Cheers,

Amanda :)
 
Upvote 0
Try this:

If any date in columns 5 to 10 are less then today that columns data will be copied to a sheet named Expired"
Run this script from the sheet with your data.

Code:
Sub License_Check()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = Sheets("Expired").Cells(Rows.Count, "A").End(xlUp).Row + 1
    For i = 3 To Lastrow
        If Cells(i, 5) < Date Or Cells(i, 6) < Date Or Cells(i, 7) < Date Or Cells(i, 8) < Date Or Cells(i, 9) < Date Or Cells(i, 10) < Date Then
            Rows(i).Copy Destination:=Sheets("Expired").Rows(Lastrowa)
            Lastrowa = Lastrowa + 1
        End If
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,052
Messages
6,128,509
Members
449,455
Latest member
jesski

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