+ Reply to Thread
Results 1 to 1 of 1

Breaking up multiple numeric ranges - questions?

  1. #1
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Breaking up multiple numeric ranges - questions?

    I am working with a list of vlan ranges. Some of these will be ranges: "101-120" or individual numbers: "150,158,201" or even a combination: "101-120,150,158,201,300-450,2000-2500".
    What I needed to do is break this up into an array that contains every number that is part of the whole listed group. That array is used to compare if a number from something else is a match; part of the listed range.
    In the numbers above, 105, 150, 302,2000,2499 or 2500 would match. But, 121, 155, 210, 1999, 2501 would not match.

    The source data comes from a Cisco switch configuration file, obtained with 'show run'. Within that text file will be an area similar to this:
    Please Login or Register  to view this content.
    I open the text file into an array, where each element of the array is loaded with the text file with the appropriate vbLf (or vbCrLf - I have a way to be sure).
    When the array is loaded (has more than -1 elements) I can use Application.Match to find the line that has the interface line I'm using.
    I will use:
    Please Login or Register  to view this content.
    If 't' is an error, it wasn't found and I can go do stuff. If the string is found, it will be a number that is an index within the array to the next line.
    In this example, sDataArray(t) will be " switchport". I will use a do-loop until I find the trailing "!".
    During that loop, I will add the numeric parts to an intermediate string until I have every line.
    The code for that, looks like this:
    Please Login or Register  to view this content.
    The variable VLANList will wind up with this (from the above example):
    "1-1316,1318-1334,1336-3371,3376-3415,3420-3423,3428-3465,3468-3483,3500-3539,3576-3587,3600-4094"

    When that variable is set, I do this:
    Please Login or Register  to view this content.
    When this is done, VLANArray will contain all the individual numbers that are within the skipping lists of numbers. I realise there is a potential glitch here, if the VLANList has no 'ranges', but is instead only a 'skip-list' (I believe I figured that out).

    I then use Application.Match to find the values I need to confirm.

    I have two questions: 1) is this horribly clunky? 2) Can I confirm that only exact matches will be found? I don't want to be looking for 310 and get a false match because the list has something like 3101.
    Last edited by Rhudi; 02-25-2014 at 10:56 AM. Reason: Correction to post

+ 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. Replies: 6
    Last Post: 07-04-2012, 09:31 AM
  2. Breaking a number into ranges of values in Excel 2010
    By skennedyaz in forum Excel General
    Replies: 5
    Last Post: 04-20-2012, 02:45 AM
  3. Macro - Breaking Number Ranges
    By rfarrell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2008, 02:27 PM
  4. [SOLVED] Match Single Numeric Criteria and Return Multiple Numeric Labels
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2005, 04:10 PM
  5. [SOLVED] Match Single Numeric Criteria and Return Multiple Numeric Labels
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-29-2005, 04:50 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