VBA: Serach column for date, cut then paste row into new sheet

Pivol

New Member
Joined
Feb 20, 2015
Messages
2
Could some kind soul please advise me on VBA coding to complete the following;


  1. Search the Completed column (G) of the ToDo List worksheet for any date entries.
  2. If any entry found to cut and paste the entire row(s) onto the Archive worksheet (Ensuring they are pasted into the next free row).
  3. Re-sort the ToDo List worksheet into order for QofA (smallest to largest), then by To Do (oldest to newest)

If this could be placed into a button then super, but tbh this is just a nice addition.

Example Worksheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]QofA[/TD]
[TD]UID[/TD]
[TD]Link[/TD]
[TD]To Do[/TD]
[TD]Ref[/TD]
[TD]Task[/TD]
[TD]Completed[/TD]
[TD]Comments[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]3[/TD]
[TD][/TD]
[TD]13/02/15[/TD]
[TD][/TD]
[TD]Test 1[/TD]
[TD]13/02/15[/TD]
[TD]SAP updated.[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD][/TD]
[TD]14/02/15[/TD]
[TD][/TD]
[TD]Test 2[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]4[/TD]
[TD][/TD]
[TD]16/02/15[/TD]
[TD][/TD]
[TD]Test 3[/TD]
[TD]15/02/15[/TD]
[TD]Task delegated ABV.[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]5[/TD]
[TD][/TD]
[TD]13/02/15[/TD]
[TD][/TD]
[TD]Test 4[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]7[/TD]
[TD][/TD]
[TD]20/02/15[/TD]
[TD][/TD]
[TD]Test 5[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks in advance.

Regards,
Clive
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi Clive. Try:
Code:
Sub CopyRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("ToDo List").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("ToDo List").Range("$A$1:$H$" & LastRow).AutoFilter Field:=7, Criteria1:="<>"
    Sheets("ToDo List").Range("$A$2:$H$" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Archive").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Sheets("ToDo List").Range("$A$2:$H$" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    If Sheets("ToDo List").FilterMode Then Sheets("ToDo List").ShowAllData
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi Clive. Try:
Code:
Sub CopyRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("ToDo List").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("ToDo List").Range("$A$1:$H$" & LastRow).AutoFilter Field:=7, Criteria1:="<>"
    Sheets("ToDo List").Range("$A$2:$H$" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Archive").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Sheets("ToDo List").Range("$A$2:$H$" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    If Sheets("ToDo List").FilterMode Then Sheets("ToDo List").ShowAllData
    Application.ScreenUpdating = True
End Sub

A HUGE thank you ever so much...this has been bugging me something rotten and is now resolved.
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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