Results 1 to 20 of 125

Thread: Combine recursive listing with excluded code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,886
    Location
    LMGTFY

    https://en.wikipedia.org/wiki/Hash_function

    A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes. The values are usually used to index a fixed-size table called a hash table. Use of a hash function to index a hash table is called hashing or scatter storage addressing.

    I had a Hash module that I added to the attachment.
    The test data in the attachment (your folder tree) was order randomized
    The MarkDupsWithHash sub was run to mark dups in red
    The data was resorted as a check


    Option Explicit
    
    
    Sub MarkDupsWithHash()
        Dim r As Range
        Dim aryHash() As String
        Dim i As Long, j As Long
        
        'test
        Worksheets("Files").Columns(1).Interior.ColorIndex = xlColorIndexNone
        
        
        Set r = Worksheets("Files").Cells(1, 1)
        Set r = Range(r, r.End(xlDown))
    
    
        ReDim aryHash(1 To r.Rows.Count)
    
    
        For i = LBound(aryHash) To UBound(aryHash)
            aryHash(i) = CreateSHA256HashString(r.Cells(i, 1).Value)
        Next i
    
    
        For i = LBound(aryHash) To UBound(aryHash) - 1
            For j = i + 1 To UBound(aryHash)
                If aryHash(j) = aryHash(i) Then r.Cells(j, 1).Interior.Color = vbRed
            Next j
        Next i
    
    
        MsgBox "Done"
    
    
    End Sub
    If you don't want to use a Hash, then the For i / For j loops should also work, but will be slower I think
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •