Duplication with criteria

marreco

Well-known Member
Joined
Jan 1, 2011
Messages
609
Office Version
  1. 2010
Platform
  1. Windows
hi

Through a code I find in column "A" values that are duplicated in column "N"should have a value >1 in the spreadsheet and paste "value".

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this. Results in Column P.
Code:
Sub twocolscode()
Dim e As Range, d As Object
Dim na As Long, nn As Long, k As Long
Set d = CreateObject("scripting.dictionary")
With Range("A:A")
na = .Cells(Rows.Count, 1).End(3).Row
For Each e In .Resize(na)
    d(e.Value) = 1
Next e
End With
With Range("N:N")
nn = .Cells(Rows.Count, 1).End(3).Row
For Each e In .Resize(nn)
    If d(e.Value) = 1 Then
        k = k + 1
        Cells(k + 1, "p") = e.Value
    End If
Next e
If k > 1 Then Cells(1, "p") = "> 1"
End With
End Sub
 
Upvote 0
Do not quite understand the code.

I ran but did not work.

What does this code do?
 
Upvote 0
Do not quite understand the code.

I ran but did not work.

What does this code do?
That code looks at all the numbers in Column A, then looks at all the numbers in Column N, then lists in Column P all the numbers that are common to both columns (duplicates).

Column P also has the heading "> 1 " that you apparently wanted "in the spreadsheet".

The code didn't paste "value" anywhere because it seems you can easily do this yourself, anywhere, anytime.

These are all the things you asked for.

If you want something else then you'd better restate your whole post.
 
Upvote 0
1, I would like the code looks for duplicates only in the column "A".

2 After you locate the duplicate values if the column "N" if more than one copy and paste the worksheet "2. "



Can you do that?

thanks
 
Upvote 0
1, I would like the code looks for duplicates only in the column "A".

2 After you locate the duplicate values if the column "N" if more than one copy and paste the worksheet "2. "

Can you do that?

thanks
Regarding 1. the following code will find duplicates in Column A. Each item that occurs more than once in Col A is listed in Col C with the number of times it occurs listed in Col D,

Regarding your 2. , I can't figure out what you mean, so won't attempt to guess.
Code:
Sub colAcode()
Dim e As Range, f, d As Object
Dim na As Long, k As Long
Set d = CreateObject("scripting.dictionary")
With Range("A:A")
na = .Cells(Rows.Count, 1).End(3).Row
For Each e In .Resize(na)
    d(e.Value) = d(e.Value) + 1
Next e
End With
For Each f In d
    If d(f) < 2 Then d.Remove f
Next f
[c1].Resize(d.Count, 2) = _
    Application.Transpose(Array(d.keys, d.items))
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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