Help: Listing Duplicate Cells

quikieemart

New Member
Joined
Jul 13, 2010
Messages
35
So I have two columns of code numbers. There are some code numbers that are the same in both columns.

Column A
1082
112
113B
2239
8449

Column B
1082
113B
488
9490A
112

Is there a way to show on Column C which code numbers are duplicates from the two lists above? The result would look like this:

Column C
1082
112
113B

Any help would be much appreciated thanks!

-Huan
 

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"
This code will do it (in worksheet code module):-
Code:
Option Explicit
 
Public Sub ExtractNames()
 
  Const FirstRow As Long = 2
  
  Dim aPtr As Long
  Dim bPtr As Long
  Dim cPtr As Long
  
  Dim lastA As Long
  Dim lastB As Long
  
  Dim blnFound As Boolean
  
  lastA = Cells(Rows.Count, 1).End(xlUp).Row
  lastB = Cells(Rows.Count, 2).End(xlUp).Row
  
  Columns("C").ClearContents
  
  cPtr = FirstRow - 1
  For aPtr = FirstRow To lastA
    blnFound = False
    For bPtr = FirstRow To lastB
      If Cells(aPtr, 1) = Cells(bPtr, 2) Then
        blnFound = True
        Exit For
      End If
    Next bPtr
    If blnFound Then
      cPtr = cPtr + 1
      Cells(cPtr, 3) = Cells(aPtr, 1)
    End If
  Next aPtr
    
  MsgBox "Done:-" & vbCrLf & vbCrLf _
       & Space(8) & CStr(lastA - FirstRow + 1) & " values in column A" & vbCrLf _
       & Space(8) & CStr(lastB - FirstRow + 1) & " values in column B" & vbCrLf _
       & Space(8) & CStr(cPtr) & " values in column C" & Space(16)
 
End Sub
Shout if you don't know what to do with this.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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