Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following assumes that your data is all in one column (eg: <code>"315 1 344"</code> is one cell)</p> <p>It will look at sheet1 starting from A1, generate a list of unique cell values and count any duplicates. Once all the records have been checked, it outputs the results to sheet2.</p> <pre><code>Sub Main() ' this requires you to add a reference to "Microsoft Scripting Runtime" (usefull if you do not know the methods of scripting.dictionary) 'Dim Results As New Scripting.Dictionary ' the line does not require you to add any extra references (there is no code-completion, you must know the methods and their arguments) Dim Results As Object: Set Results = CreateObject("Scripting.Dictionary") Dim Data As Variant Dim Key As Variant Dim Source As Worksheet: Set Source = ThisWorkbook.Worksheets("Sheet1") ' the sheet where your data is Dim Destination As Worksheet: Set Destination = ThisWorkbook.Worksheets("Sheet2") ' where the results will be put Dim Row As Long: Row = 1 ' the row number to start from Dim Item As String Data = Source.UsedRange.Value2 ' iterate over the data Do Item = Data(Row, 1) If Results.Exists(Item) = True Then Results(Item) = Results(Item) + 1 Else Results(Item) = 1 End If Row = Row + 1 Loop While Not Data(Row, 1) = "" ' display the output Destination.Cells.Clear ' reset the worksheet For Each Key In Results.Keys ' loop through the results Destination.Range("A1:B1").Insert xlShiftDown ' move the previous results down Destination.Cells(1, 1) = Key Destination.Cells(1, 2) = Results(Key) Next Key End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload