+ Reply to Thread
Results 1 to 10 of 10

Find IP address in subnet range and return text

  1. #1
    Registered User
    Join Date
    03-12-2010
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Find IP address in subnet range and return text

    What I am trying to do is compare an IP address in a cell to a list of IP ranges and return what location the IP range is for. So for example for:

    IP Address--------------- City
    192.168.100.50

    Column A-------------Column B-----------Column C
    192.168.100.1-------192.168.100.254--------Ohio
    10.10.10.1-------------10.10.10.254-------Texas

    Should return for 'City' column

    Ohio


    I have done something similar with plain text with this:

    =IF(ISERROR(MATCH($A1,$H$3:$H$604,0)),"",VLOOKUP($A1,$H$3:$J$604,2,0))

    But that is looking for an exact match not in a range of column A and B. More than anything I am looking for a direction to take. Should I be working with a different function, etc., since these are IP address/numbers and I am looking in a range instead of a match. Any help is appreciated, thank you.
    Last edited by jpalmer99; 08-19-2010 at 03:08 PM. Reason: Solved

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find IP address in subnet range and return text

    I am not an expert with IP addresses.. but I thought perhaps if you remove all the dots and convert to a number, you can use that to compare.

    I also assume your fogot a .100 in the B column (first entry)

    So if your input is in F2, then try:

    Please Login or Register  to view this content.
    adjust ranges to suit.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    03-12-2010
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Find IP address in subnet range and return text

    That almost got me there, a city is being returned. But it seems to be returned only the first city on the list in my example:

    A------------------------B----------------------------C---------------D---E--------D------------------------F
    Start-------------------End ------------------------City
    192.168.100.1----192.168.100.254--------Austin-----------------------192.168.101.50-----Austin
    192.168.101.1----192.168.101.254--------Jacksonville----------------192.168.104.33----Austin
    192.168.102.1----192.168.102.254--------Los Angeles
    192.168.103.1----192.168.103.254--------Shelby
    192.168.104.1----192.168.104.254--------New York
    192.168.105.1----192.168.105.254--------Seattle

    I think you have me on the right track and I am working with the formula.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find IP address in subnet range and return text

    I guess I didn't think clearly initially... we will have to see if there is a better way...

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find IP address in subnet range and return text

    Just another guess... but if you have your database sorted in ascending order by column A (the start IPs)... does this work?


    =LOOKUP(F2,$A$2:$C$8)

    where F2 contains the lookup IP and A2:C8 the database.

  6. #6
    Registered User
    Join Date
    03-12-2010
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Find IP address in subnet range and return text

    Yep that seems worked perfectly. So obviously I was making that a whole lot harder than it needed to be. Thank you.

  7. #7
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Re: Find IP address in subnet range and return text

    Ok. Similar but not exact question.

    I have:

    192.168.100.1
    10.10.10.1

    I am trying to get:

    192.168.100
    10.10.10

    Basically return the first set of 3 numbers after the . second dot

    Thanks in advance.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Find IP address in subnet range and return text

    VegasL,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Re: Find IP address in subnet range and return text

    Sorry about that. Ok I'll start new thread. Thanks for the insight.

  10. #10
    Registered User
    Join Date
    08-22-2013
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Find IP address in subnet range and return text

    I know this is dated but I'm struggling to do the same thing. When I use just the lookup formula I get N/A. can you share the final formula you used? Was any formating of the ip addresses required?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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