Should this code be written differently? Takes way longer than sorting each sheet manually

strat919

Board Regular
Joined
May 15, 2019
Messages
54
Sorry....maybe I was misunderstood.

only a zero distance would show up in the results if there were any duplicates in the AB column
 
Last edited:

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

strat919

Board Regular
Joined
May 15, 2019
Messages
54
AB
142.482220.7458
242.213920.7397
342.914420.6897
442.578121.5803
542.321421.3583
642.914420.6897

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



ABCDE
142.914420.689742.914420.68970
242.213920.739742.482220.745818.54432
342.321421.358342.578121.580321.04423
442.914420.689742.482220.745830.00411
542.321421.358342.213920.739732.49618
642.321421.358342.482220.745833.1735
742.578121.580342.482220.745843.01226
842.914420.689742.213920.739748.47707
942.578121.580342.213920.739749.73902
1042.914420.689742.578121.580350.8234
1142.914420.689742.321421.358353.24988

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Results 190727 7.38 am

Row 3 and 6 are duplicates so it showed up one time as 0 distance in results
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,385
Office Version
365
Platform
Windows
:confused:
How can there be duplicates in AB ?
- the code should remove duplicates in this line
Code:
[I][COLOR=#006400]'[/COLOR][COLOR=#ff0000]remove duplicate co-ordinates [/COLOR][COLOR=#006400]and place remaining values in array[/COLOR][/I]
    Data.Range("A:B").RemoveDuplicates Columns:=Array(1, 2)
 
Last edited:

strat919

Board Regular
Joined
May 15, 2019
Messages
54
The duplicates should not be "removed" in the code. There will be very few cases where there will exact duplicates...... but I would need to see if there were any..... and they would appear at the top of the results as the the shortest distance being zero distance.

I guess everything would work perfectly if the code simply didn't remove any exact duplicates.

I hope this makes sense to you:)
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,385
Office Version
365
Platform
Windows
Why not simply delete the line that removes duplicates ?
 

strat919

Board Regular
Joined
May 15, 2019
Messages
54
I didn't delete the entire line.

It works perfectly now:) Thank you so much for your help Mr Yongle!
 

Watch MrExcel Video

Forum statistics

Threads
1,102,872
Messages
5,489,411
Members
407,687
Latest member
NeoSez

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top