Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2015, 05:25 AM
macropod's Avatar
macropod macropod is offline find IP in range / find number between numbers Windows 7 64bit find IP in range / find number between numbers Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


If you sort the data in columns F-H so the IP ranges are in ascending order, thus:
Code:
Internal-restricted    10.100.1.0       10.100.1.63
Internal-voip         10.100.1.64      10.100.1.127
Internet-Zone 2         83.1.25.0       83.1.25.255
Internet-Zone 1     109.11.93.192     109.11.92.255
DMZ                  192.168.20.0    192.168.20.255
in D13 you can use an array formula like:
Code:
=INDEX($G$2:$G$7,MATCH(TEXT(LEFT(C13,FIND(".",C13)),"000")&TEXT(MID(C13,FIND(".",C13)+1,FIND(".",C13,FIND(".",C13)+1)-1-FIND(".",C13)),"000")&TEXT(MID(C13,FIND(".",C13,FIND(".",C13)+1)+1,FIND(".",C13,FIND(".",C13,FIND(".",C13)+1)+1)-1-FIND(".",C13,FIND(".",C13)+1)),"000")&TEXT(MID(C13,FIND(".",C13,FIND(".",C13,FIND(".",C13)+1)+1)+1,LEN(C13)),"000"),TEXT(LEFT($H$2:$H$7,FIND(".",$H$2:$H$7)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7)+1,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)-1-FIND(".",$H$2:$H$7)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1)-1-FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1)+1,LEN($H$2:$H$7)),"000"),1))
Note: You should probably also interleave the valid ranges with the IP addresses that are invalid (e.g. 83.1.26.0 - 109.11.93.191), otherwise you may end up with false matches. If you can't do that and there is a risk of IP addresses that are invalid being input, a rather more complex version of the above formula would be required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 06-14-2015, 11:59 AM
gn28 gn28 is offline find IP in range / find number between numbers Windows 7 64bit find IP in range / find number between numbers Office 2010 32bit
Novice
find IP in range / find number between numbers
 
Join Date: Jun 2015
Posts: 2
gn28 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
If you sort the data in columns F-H so the IP ranges are in ascending order, thus:
Code:
Internal-restricted    10.100.1.0       10.100.1.63
Internal-voip         10.100.1.64      10.100.1.127
Internet-Zone 2         83.1.25.0       83.1.25.255
Internet-Zone 1     109.11.93.192     109.11.92.255
DMZ                  192.168.20.0    192.168.20.255
in D13 you can use an array formula like:
Code:
=INDEX($G$2:$G$7,MATCH(TEXT(LEFT(C13,FIND(".",C13)),"000")&TEXT(MID(C13,FIND(".",C13)+1,FIND(".",C13,FIND(".",C13)+1)-1-FIND(".",C13)),"000")&TEXT(MID(C13,FIND(".",C13,FIND(".",C13)+1)+1,FIND(".",C13,FIND(".",C13,FIND(".",C13)+1)+1)-1-FIND(".",C13,FIND(".",C13)+1)),"000")&TEXT(MID(C13,FIND(".",C13,FIND(".",C13,FIND(".",C13)+1)+1)+1,LEN(C13)),"000"),TEXT(LEFT($H$2:$H$7,FIND(".",$H$2:$H$7)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7)+1,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)-1-FIND(".",$H$2:$H$7)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1)-1-FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)),"000")&TEXT(MID($H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7,FIND(".",$H$2:$H$7)+1)+1)+1,LEN($H$2:$H$7)),"000"),1))
Note: You should probably also interleave the valid ranges with the IP addresses that are invalid (e.g. 83.1.26.0 - 109.11.93.191), otherwise you may end up with false matches. If you can't do that and there is a risk of IP addresses that are invalid being input, a rather more complex version of the above formula would be required.
Hi there,
First of all, thanks for the helping hand.

Was I suppose to do something special with the formula?
I am getting "a value used in the formula is of the wrong data type" error.

Thanks in advance
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find number of coma and then add that number of rows in word using macro? PRA007 Word VBA 7 05-27-2015 10:45 PM
find IP in range / find number between numbers Help!! find two number recurring numbers in row?? carrolld2 Excel 5 06-28-2014 05:43 PM
Find and Delete Rows based on a range damaniam Excel Programming 2 03-12-2014 06:06 AM
find IP in range / find number between numbers Find and Replace using Excel range dmarie123 Word VBA 15 04-02-2013 07:54 AM
Find and Replace within range anil3b2 Word VBA 3 12-01-2010 02:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft