+ Reply to Thread
Results 1 to 13 of 13

Get a location from an IP Address range

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Get a location from an IP Address range

    Hey all,

    Definitely not a pro, but I usually can fumble my way through Excel well enough, but alas I need some help.

    I am loosing a tool that did this for me, but what I need to do is resolve a location based on an ip from a table of ranges and locations. I extracted our DNS tables from Active Directory and am now trying to figure out how to make this work, but I suspect that the fact that IP's are in octets its screwing up any regular formulas, just not sure how to properly break them up or change them. I have tried a ranged vlookup, but it wont capture most of the IP's. If this has already been answered somewhere, feel free to point me in that direction as I am not finding it. I have attached a sample file, but basically here's what I need to lookup.

    Column A Column B Column C Column D Column E Column F
    Beginning IP Ending IP Location IP Location Lookup
    192.168.0.1 192.168.0.255 Location A 192.168.0.1 Need answer here
    201.202.0.0 201.202.0.255 Location B 192.168.0.20 Need answer here
    192.168.0.200 Need answer here
    201.202.0.75 Need answer here
    201.202.0.245 Need answer here


    I have Office Pro Plus 2016 and Kutools 16 installed

    Thanks all
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    Ugh, that description turned into a mess, sorry about that.

  3. #3
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Get a location from an IP Address range

    =vlookup(left(f2,9)&"*",$a$2:$c$18,3,)

  4. #4
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    Quote Originally Posted by tim201110 View Post
    =vlookup(left(f2,9)&"*",$a$2:$c$18,3,)

    Thanks, that only partially works. If there is nothing, or maybe an error it gives me a default of Location A. Also if I change the 3rd octet, it does not appear to recognize it. For example 201.202.010.245 gives me a location of B when it should not match anything.

  5. #5
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    Quote Originally Posted by arcsum68 View Post
    Thanks, that only partially works. If there is nothing, or maybe an error it gives me a default of Location A. Also if I change the 3rd octet, it does not appear to recognize it. For example 201.202.010.245 gives me a location of B when it should not match anything.
    Actually if I change that to 201.202.10.245 it works, must be the preceding 0.

    Also if I put anything above the range, it's still not working correctly. For example 201.202.0.256 returns location B.
    Last edited by arcsum68; 10-30-2017 at 04:54 PM.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Get a location from an IP Address range

    If you want to match anything before last "." exactly. Then use...
    =INDEX($C$2:$C$3,MATCH(LEFT(F2,FIND(".",F2,9))&"*",$A$2:$A$3,0))
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  7. #7
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    Quote Originally Posted by CK76 View Post
    If you want to match anything before last "." exactly. Then use...
    =INDEX($C$2:$C$3,MATCH(LEFT(F2,FIND(".",F2,9))&"*",$A$2:$A$3,0))
    I am not sure that is looking within the range. For example 192.168.0.256 returns with Location A when it should be nothing.

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Get a location from an IP Address range

    g2=IFERROR(LOOKUP(2,1/((SUBSTITUTE($A$2:$A$3,LEFT(F2,10),"")+0<=MID($F2,11,10)+0)*(SUBSTITUTE($B$2:$B$3,LEFT(F2,10),"")+0>=MID($F2,11,10)+0)),$C$2:$C$3),"not found")
    Try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  9. #9
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    Quote Originally Posted by nflsales View Post
    g2=IFERROR(LOOKUP(2,1/((SUBSTITUTE($A$2:$A$3,LEFT(F2,10),"")+0<=MID($F2,11,10)+0)*(SUBSTITUTE($B$2:$B$3,LEFT(F2,10),"")+0>=MID($F2,11,10)+0)),$C$2:$C$3),"not found")
    Try this and copy towards down
    Wow, nice. This is really close, but still having issues with in a few scenarios, though I am not really sure why.

    Most of my shorter IP's are having a problem where its not finding them, I included a new sample so you can see where some of them are failing but I am not sure why.
    Attached Files Attached Files

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Get a location from an IP Address range

    You can try below to make it dynamic.
    =IFERROR(LOOKUP(2,1/((SUBSTITUTE($A$2:$A$8,LEFT(F2,FIND("^",SUBSTITUTE(F2,".","^",3))),"")+0<=MID($F2,FIND("^",SUBSTITUTE(F2,".","^",3))+1,10)+0)*(SUBSTITUTE($B$2:$B$8,LEFT(F2,FIND("^",SUBSTITUTE(F2,".","^",3))),"")+0>=MID($F2,FIND("^",SUBSTITUTE(F2,".","^",3))+1,10)+0)),$C$2:$C$8),"not found")

    However, your last row, has two different value between 2nd "." and last "." in Column A & B.
    248 vs 255. Formula won't be able to accommodate for that.

  11. #11
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    I have 40 out of 500 like that, I could make a range for each one. So instead of

    141.181.248.0-141.181.255.255

    it would be

    145.181.248.0 145.181.248.255
    145.181.249.0 145.181.249.255
    145.181.250.0 145.181.250.255
    145.181.251.0 145.181.251.255
    145.181.252.0 145.181.252.255
    145.181.253.0 145.181.253.255
    145.181.254.0 145.181.254.255
    145.181.255.0 145.181.255.255

    Let me play with that, thanks!

  12. #12
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Get a location from an IP Address range

    as a way with helper columns
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-01-2010
    Location
    Sacramento, CA
    MS-Off Ver
    O365
    Posts
    70

    Re: Get a location from an IP Address range

    So I suck and didnt get back to you on this because I got sidetracked. Spent today plugging away at the data table I had to create to make the formula work, and it works very well.

    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. Return 1st occurrence of IP address and Location
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-14-2017, 06:36 AM
  2. Match IP address to Office Location
    By griam01 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-31-2016, 12:07 PM
  3. [SOLVED] Get cell address (range) from shape location
    By Fattyfatfat Kid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-30-2015, 05:33 PM
  4. Ip address to GEO Location finding
    By Subarna in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-06-2014, 07:02 AM
  5. How to add to a particular cell location given by the formula =address(...)
    By weekssm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2014, 10:43 AM
  6. Macro location address
    By ResPlanningPro in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-03-2011, 09:52 PM
  7. Cell Address Location
    By drizzt04240 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-01-2005, 11:49 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