+ Reply to Thread
Results 1 to 3 of 3

VBA routine to compare 2 datasets and remove points closer than 30m.

  1. #1
    Registered User
    Join Date
    07-07-2016
    Location
    Kuwait
    MS-Off Ver
    2016
    Posts
    28

    VBA routine to compare 2 datasets and remove points closer than 30m.

    Hi,

    Hoping someone can help with this (I'm not a VBA programmer).

    The attached file has a plot with 2 datasets: a blue dataset and an orange dataset. Each one is X,Y coordinates.

    I would like to end up with a reduced blue dataset by deleting any blue dataset points that are further than 30m from the nearest orange point.

    In other words none of the blue dataset points must be further than 30m from the nearest orange point but we keep the ones that are within 30m.

    Any pointers appreciated.

    Thanks,
    Attached Files Attached Files

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA routine to compare 2 datasets and remove points closer than 30m.

    Your column that calculates distance is only calculating to the corresponding x and y in the next column, it is not comparing to ALL the other X,Y data in the orange dataset column.

    To compare against ALL the other data you'll need to use this formula instead entered as an array formula (Control + shift + enter).

    Please Login or Register  to view this content.
    Use the whole formula to determine which data points are further than 30m (they will be indicated by a *) or use the red part of the formila only to determine the closest distance.

    I ran your data though and there aren't that many that fall within 30m, most are greater than 30m except for the first point (your origin at 0,0).

    If this calculation is the way you want it to work you'll need to fix that part first (or build that into the Macro).

    Happy to assist if this has to be macro driven but needed to clarify the method for calculation first.
    Happy with my advice? Click on the * reputation button below

  3. #3
    Registered User
    Join Date
    07-07-2016
    Location
    Kuwait
    MS-Off Ver
    2016
    Posts
    28

    Re: VBA routine to compare 2 datasets and remove points closer than 30m.

    Thanks for your help! I wasn't able to enter the formula as an array (for some reason CSE didn't have any effect) but the formula works anyway and located the required points.
    Many thanks.

+ 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. Moving all data points closer to the trend line on a graph
    By curiousasd in forum Excel Charting & Pivots
    Replies: 14
    Last Post: 09-25-2019, 09:18 AM
  2. Replies: 7
    Last Post: 03-23-2018, 08:27 PM
  3. Replies: 8
    Last Post: 07-07-2016, 05:22 PM
  4. Routine to compare two range of cells and output an array
    By dmarzo1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2013, 08:26 AM
  5. [Macro] Remove blank rows (apart from 1 to separate datasets)
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2011, 05:41 PM
  6. Compare if column A or B closer to 0 and color column C
    By TobiManobi in forum Excel General
    Replies: 4
    Last Post: 10-05-2009, 12:03 AM
  7. Compare two sheets and perform action routine
    By wayliff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2006, 04:28 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