Results 1 to 3 of 3

Thread: How to discover repeat text names in Range array?

Threaded View

  1. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: How to discover repeat text names in Range array?

    it ‘s very long. How can I do it faster?
    If you sort the array and then do check, that will also be longer. The best way is to copy the array to excel cells and then sort them and then compare them. that is the fastest...

    For Example (Please amend it as per you requirements...)

    vb Code:
    1. Sub aaa()
    2.  
    3. 'Defining my array for test purpose
    4. Dim ar(21)
    5. For i = 1 To 20
    6.     ar(i) = "aaa" & i
    7.     'Creating a duplicate value
    8.     ar(21) = "aaa1"
    9. Next i
    10.  
    11.  
    12. 'Copy Data to Sheet
    13. For j = 1 To 21
    14.     Sheets("sheet1").Range("A" & j) = ar(j)
    15. Next j
    16.  
    17. 'Sort The data
    18. Range("A1").Select
    19. Range(Selection, Selection.End(xlDown)).Select
    20. Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
    21. OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    22. DataOption1:=xlSortNormal
    23.  
    24. 'Do the Comparing
    25. For k = 1 To 21
    26.     If Range("A" & (k + 1)).Value = Range("A" & k).Value Then
    27.         MsgBox "Match Found"
    28.     End If
    29. Next k
    30.  
    31. End Sub
    Last edited by Siddharth Rout; Apr 14th, 2008 at 10:28 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width