Remove Duplicates and move rows across sheets

whitoulias

Board Regular
Joined
Jun 22, 2012
Messages
153
Hi,

First of all let me thank in advance anyone who will take time to read and propose any solutions.

I have 4 worksheets and ideally i am looking for perhaps a command button in sheet (1) which will perform the following. This kind of check will be held daily every 30 minutes to 1 hour by different people.

(1) Incoming. This is retrieved through a web query from a trusted link from our partners representing the color of textiles and the date they will be delivered. We don't care about the batch number. Removing duplicates should be based on color and date (dd/mm/yyyy hh:mm)
Sorting.xlsx
ABC
1ColourDateBatch
2Orange06/05/2021 17:301
3Orange06/05/2021 17:305
4Orange06/05/2021 17:3032
5Green06/05/2021 10:30354
6Green06/05/2021 10:3034
7Green06/05/2021 10:3012
8White07/05/2021 19:307
9White07/05/2021 19:3089
10White07/05/2021 19:3090
11Yellow08/05/2021 01:0034
12Yellow08/05/2021 01:0056
13Yellow08/05/2021 01:0078
14Red09/05/2021 22:006
15Red09/05/2021 22:008
16Red09/05/2021 22:004
17Purple10/05/2021 14:00123
18Purple10/05/2021 14:0056
19Purple10/05/2021 14:0012
Incoming


(2) Checked. Once duplicates are sorted, only the colors which are included in sheet (4) should be moved here, where 2 members will perform their controls. Once the (now) time reaches the delivery time, the whole row should be moved to sheet (3)

Sorting.xlsx
BCDEFG
1ColourDate1st CheckInitials2nd CheckInitials
2Green06/05/2021 10:30No issuesJDNo issuesNF
3Yellow08/05/2021 01:00No issuesJDNo issuesNF
4Red09/05/2021 22:001 issue - ResolvedJDNo issuesNF
Checked


(3) Archived

Sorting.xlsx
BCDEFG
1ColourDate1st CheckInitials2nd CheckInitials
2Green03/05/2021 10:30No issuesJDNo issuesNF
3Yellow04/05/2021 01:00No issuesJDNo issuesNF
4Red05/05/2021 22:001 issue - ResolvedJDNo issuesNF
Archived


(4) Sample. This sheet will remain hidden and everyday a member of the staff will update the colors accordingly
Sorting.xlsx
A
1Colours to be Checked Today
2Red
3Yellow
4Green
Sample
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
After browsing I have come up with this code which is actually working good. Could anyone help me amend the last part (For r = 1 To lr1) so instead of a simple copy paste to perform a cut+paste so empty rows can be deleted from the source sheet (rs1)?

Thank you

VBA Code:
Sub ColorCheck()

Dim Lastrow As Long
Dim rs1 As Worksheet, rs2 As Worksheet, rs3 As Worksheet
Dim y As Date

y = Now
Set rs1 = Sheets("Incoming")
Set rs2 = Sheets("Checked")
Set rs3 = Sheets("Archived")

Application.ScreenUpdating = False

Lastrow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row '

    ActiveSheet.Range("$A$1:$C" & Lastrow).RemoveDuplicates Columns:=1, Header:= _
        xlYes

lr1 = rs1.Range("A" & Rows.Count).End(xlUp).Row
lr2 = rs2.Range("B" & Rows.Count).End(xlUp).Row

For r = 1 To lr2

If rs2.Cells(r, "B") < y Then
    rs2.Cells(r, "A").EntireRow.Copy Destination:=rs3.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If

Next r

For r = 1 To lr1

If rs1.Cells(r, "A") = "Green" Or rs1.Cells(r, "A") = "Red" Then
    rs1.Cells(r, "A").EntireRow.Copy Destination:=rs2.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If

Next r


Application.ScreenUpdating = True

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,721
Messages
6,174,091
Members
452,542
Latest member
Bricklin

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