+ Reply to Thread
Results 1 to 9 of 9

VBA to Check overlapping numbers.

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    USA, Kentucky
    MS-Off Ver
    Office 2013
    Posts
    25

    VBA to Check overlapping numbers.

    I have a sheet which contains a range (G6:AM87). Users can enter numbers into this range. These numbers do NOT necessarily fill the range.

    I am looking for a VBA script to analyze those cells which contain numbers to ensure every number is at least 8 digits apart from any other number in said range.
    If all numbers are spaced 8 digits or more the range containing data is colored green. However if two numbers are less than 8 digits apart they get colored red.

    For example:

    If the range contains the numbers 8 and 15 they would be colored red because they overlap less than 8 digits.


    Hope this helps define what I need.


    Thanks for any and all assistance!

    ~Rob

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Check overlapping numbers.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA to Check overlapping numbers.

    Why not just use conditional formatting?

    =COUNTIFS($G$6:$J$14, ">=" & G6-7, $G$6:$J$14, "<=" & G6+7)>1
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    01-25-2013
    Location
    USA, Kentucky
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: VBA to Check overlapping numbers.

    Thanks for the responses. The conditional format was near what I needed but this may explain more of what I need.

    Thanks again!
    ~Rob

    Example.xlsm

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Check overlapping numbers.

    Nevermind

  6. #6
    Registered User
    Join Date
    01-25-2013
    Location
    USA, Kentucky
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: VBA to Check overlapping numbers.

    Quote Originally Posted by xladept View Post
    Nevermind
    xladept,

    Too complicated or is it not even possible using Excel?

  7. #7
    Registered User
    Join Date
    01-25-2013
    Location
    USA, Kentucky
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: VBA to Check overlapping numbers.

    I'm getting a circular reference error with this in Cell if statement. Can someone see if they can clean it up for me?

    Please Login or Register  to view this content.
    Thanks,

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Check overlapping numbers.

    Hi RJ,

    I think it's too complicated - is there a range of permissible numeric entries??

  9. #9
    Registered User
    Join Date
    01-25-2013
    Location
    USA, Kentucky
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: VBA to Check overlapping numbers.

    Quote Originally Posted by xladept View Post
    Hi RJ,

    I think it's too complicated - is there a range of permissible numeric entries??
    No its essentially a timing sequence. The user enters the delay between two points then the first value (starting point) is added to the user entered delay time, and applied to the linked point.

    Eg: Point A's value is 42. User links it to point B with a 17. Point B becomes 42 +17 = 59 and so on and so forth. I just need to check that, any point - any other point > 7.


    hope that clears things up a bit.

+ 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] Check same and adjacent numbers
    By syed01 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-25-2013, 10:27 AM
  2. Using Excel to check for overlapping times
    By evandp01 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2012, 05:21 PM
  3. Replies: 0
    Last Post: 09-13-2011, 01:03 AM
  4. Counting Overlapping Time & Non-Overlapping Time
    By I_need_help1 in forum Excel General
    Replies: 4
    Last Post: 02-08-2011, 02:36 PM
  5. Range lookups with overlapping entries and extra check
    By mstegehu in forum Excel General
    Replies: 3
    Last Post: 07-05-2010, 09:02 AM

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