Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

VBA question. I am trying to write a code that will copy the rows that have Duplicate in the O column and then paste the

VBA question.

I am trying to write a code that will copy the rows that have "Duplicate" in the O column and then paste the entire row to Sheet2. But I have been confused on what to use. Below is a copy of the code.

Sub SimpleLoop()

Dim Duplicate As Variant Dim LastRow As Integer

LastRow = Application.CountA(Range("A:A")) Application.ScreenUpdating = False

Worksheets("Sheet1").Activate Range("A2").Select Range("O2").Select ActiveCell.FormulaR1C1 = _ "=IF(COUNTIF(C[-9],RC[-9])>1,""Duplicate"",""Unique"")" Range("O2").Select Selection.AutoFill Destination:=Range("O2:O" & LastRow) For RowToTest = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1

With Cells(RowToTest, 13) If .Value = "Duplicate" Then Rows(RowToTest).EntireRow.Cut Sheets("Sheet2").Select ActiveSheet.Paste

End If End With

Next RowToTest

Application.CutCopyMode = False Application.ScreenUpdating = True End Sub

Below is the excel sheet that I am using.

Order Tier Value First Last Email Address City State Zip Phone DOB TimeStamp
1 1 12344 Rob Brown brown@email.com 123 Popular Dr Rock NC 28731 2222222 6/15/1938 7/31/2018 16:59
2 1 45657 Caroline Ribbon ribbon@email.com 123 Rocky Point Jacksonville FL 28540 2222222 2/5/1964 7/31/2018 22:14
4 1 6789 Lisa McDonald lisa@email.com 219 Wall Road Greensboro NC 28338 2222222 7/24/1978 8/1/2018 21:25
4 1 99999 Lisa McDonald lisa@email.com 219 Wall Road Greensboro NC 28338 2222222 7/24/1978 8/1/2018 21:25
5 1 8764 Don Lee don@email.com 222 Castlerock NASHVILLE TN 27856 2222222 7/29/1949 7/31/2018 15:38

Thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions