+ Reply to Thread
Results 1 to 9 of 9

find duplicate range , position range

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    find duplicate range , position range

    hello friends ,

    i try to find solution , but wasn't able to find

    i have two sheets , one with IDS another with POSITION ,

    with IDS sheet i have many ids fill till A2:J3721

    in ids sheet i have range A2:A25 , A26:A49 and so on till A3721

    is it possible to find duplicate range of A2:A25 in entire sheet ....

    and to name those range of duplicate range in position sheet .

    and so on after A2:A25 and so on ,

    for better understanding i have attach sample file . SAMPLE FILE1.xlsx

    also if possible can we color all duplicates range with unique color ..
    Last edited by raj soni; 12-04-2014 at 09:30 AM.

  2. #2
    Registered User
    Join Date
    09-26-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: find duplicate range , position range

    Hello,

    For quick reply a short macro that looks in column A for the sequence a,b,c.
    If this is the case all three cells will be made red.

    Set up a sheet with in a same bogus values with sometime the sequence a, b and c in consecutieve rows. (row 4 = a, row 5 = b and row 6 = c)

    This macro can be built out for your convenience with all parameters.

    Sub test()
    Dim c As Range
    Dim lastrow As Long
    Dim color As Long
    
    lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    
    For Each c In Sheets(1).Range("A1:A" & lastrow).Cells
        If c.Value = "a" Then
            If c.Offset(1) = "b" And c.Offset(2) = "c" Then
                c.Resize(3).Interior.ColorIndex = 3
            End If
        End If
    Next c
    
    End Sub
    Reg.
    Demeter

  3. #3
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: find duplicate range , position range

    thanks , Demeter
    but i have to look for duplicate range that is a2:a25 , not just one cell .
    also , in position sheet , if possible , name position of those duplicate ranges

  4. #4
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: find duplicate range , position range

    Option Explicit
    Sub ColorCriteria()
        Dim rCriteria As Range
        Dim rData As Range
        Dim c As Range, r As Range
        Dim sFirstAddress As String
        Dim ColorCounter As Long
        Dim StartTime As Single, EndTime As Single
    
    StartTime = Timer
    Set rCriteria = Range("A49:A72", "A73:A96")
    
    
    
    Set rData = Range("A1:X54001")
    
    Application.ScreenUpdating = False
    With rData
    For Each r In rCriteria
        If Not r = "" Then
        Set c = .Find(what:=r.Value, LookIn:=xlValues, lookat:=xlWhole, _
                searchdirection:=xlNext)
        If Not c Is Nothing Then
            sFirstAddress = c.Address
            c.Interior.Color = vbRed
    
            Do
                Set c = .FindNext(c)
                c.Interior.Color = vbRed
                ColorCounter = ColorCounter + 1
            Loop Until c.Address = sFirstAddress
        End If
        End If
    Next r
    
    End With
    Application.ScreenUpdating = True
    EndTime = Timer
    
    MsgBox ("Execution Time: " & Format(EndTime - StartTime, "0.000"" sec""") _
        & vbLf & "Colored Cell Count: " & ColorCounter)
    
    
    End Sub
    hello frds how i can use above code with
    "A1:A24"
    "A25:A48"
    "A49:A72"
    "A73:A96"
    "A97:A120"
    "A121:A144"
    "A145:A168"
    ranges ....till A54001
    difference between range is 23 cells .
    Last edited by raj soni; 12-04-2014 at 09:11 AM.

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: find duplicate range , position range

    When I do a quick check on duplicates in column "A" , I find there are no duplicates at all, If there are no duplicates in column "A" , then there are no duplicates in each Range of 25 cells, in column "A". so Am I looking for the right thing?????

  6. #6
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: find duplicate range , position range

    sir , i am looking for duplicate range of a2:a25 in entire sheet ,

    Set rData = Range("A1:X54001")

    i am unable , to loop every next 23 range of cells to find in entire sheet .

    right now i have to entry this ranges manually .

    "A1:A24"
    "A25:A48"
    "A49:A72"
    "A73:A96"
    "A97:A120"
    "A121:A144"
    "A145:A168"
    ranges ....till A54001
    Last edited by raj soni; 12-04-2014 at 09:38 AM.

  7. #7
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: find duplicate range , position range

    Try this:-
    Sub MG04Dec09
    Dim Rng As Range, Dn As Range
    Dim Lst As Long, n As Long, c As Long
    Dim Frng As Range, Ac As Long, col As Long
    Dim RStg As String, p As Long, K As Variant
    Dim Q As Variant, Sp As Variant
    
    Lst = Range("A" & Rows.Count).End(xlUp).Row
    With CreateObject("scripting.dictionary")
    .CompareMode = vbTextCompare
    For n = 2 To Lst Step 24
        For Ac = 1 To 24
            Set Frng = Range(Cells(n, Ac), Cells(n + 23, Ac))
            RStg = Join(Application.Transpose(Frng))
            If Not .Exists(RStg) Then
                .Add RStg, Array(Frng, Frng.Address)
            Else
                Q = .Item(RStg)
                Q(1) = Q(1) & "," & Frng.Address
                .Item(RStg) = Q
            End If
        Next Ac
    Next n
    c = 1
    For Each K In .keys
        c = c + 1
        Sheets("Position").Cells(c, 1) = .Item(K)(0).Address
        Sp = Split(.Item(K)(1), ",")
            For p = 1 To UBound(Sp)
                Sheets("Position").Cells(c, p + 1) = Sp(p)
            Next p
    Next K
    MsgBox "Run"
    End With
    End Sub
    Regards Mick

  8. #8
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: find duplicate range , position range

    thank you sir , its working perfectly .....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Change column reference within a range by numeric position within the range
    By SteveSwitch in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-19-2013, 08:21 AM
  2. Find the position of a value within a rectangular range
    By Larry.LeBlanc@O in forum Excel General
    Replies: 6
    Last Post: 10-27-2011, 06:21 PM
  3. to find duplicate cell in a range
    By mingali in forum Excel General
    Replies: 4
    Last Post: 06-03-2010, 03:27 PM
  4. Find duplicate values within a range
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2008, 10:47 AM
  5. [SOLVED] Find the POSITION IN A RANGE of text in a string that matches value(s) in a range
    By Cornell1992 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 03:25 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1