Search for an IP address Using a Set of Ranges as Search Criteria

meppwc

Well-known Member
Joined
May 16, 2003
Messages
626
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a tool that will allow you to paste a column of IP addresses and have each address searched for in a range of IP addresses. For each address found in a range then Excel returns "yes", otherwise "no"

The table below is a sample of the pasted addresses (column F)
To the right is where the formula would be (column G) and what you would expect the formula to return (yes/no)
The table below that is the IP Ranges searched on (columns A and B)
I was able to figure out a formula that will search on the first row of ranges but cannot figure out how to search on the full set of ranges
=IF(AND((F1>=A1),(F1<=B1)),"yes","no")


Search Result
10.126.192.21 yes
10.126.197.26 yes
10.20.140.33 no


IP Ranges
From To
10.126.192.21 10.126.192.22
10.126.193.21 10.126.193.22
10.126.194.22 10.126.194.23
10.126.195.21 10.126.195.26
10.126.196.22 10.126.196.23
10.126.197.25 10.126.197.28
10.126.198.22 10.126.198.26
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I am going to repost and try to make my original attempt less confusing

Below is a table of seven IP address ranges
The addresses are located from A2:B8

From To
10.126.192.21 10.126.192.22
10.126.193.21 10.126.193.22
10.126.194.22 10.126.194.23
10.126.195.21 10.126.195.26
10.126.196.22 10.126.196.23
10.126.197.25 10.126.197.28
10.126.198.22 10.126.198.26

Lets suppose that in cell C2 I manually input the IP address of 10.126.192.21
I need a way to search for the value in C2 throughout the ranges of addresses in A2:B8
If found, then D2 would return a value of "yes". If not found within the ranges then D2 would return the value of "no"

I need a formula for D2
I created the following formula but will only search A2:B2
=IF(AND((C2>=A2),(C2<=A2)),"yes","no")

Is there a way to expand on my formula to search all the column (A2:B8) ?
 
Upvote 0
If you're putting data in C2, then in cell D2 insert the following formula:
=IF(COUNTIF(A:B;C2)>0,"yes","no")
 
Upvote 0
ScatmanKyle
Thank you for the response
I am not getting the results that I would expect to get
By using your formula and using the value of 10.126.198.24 in C2
The formula returns "no".
It should return "yes" because C2 (10.126.198.24) is in the range 10.126.198.22 - 10.126.198.26 that is in the last line of my table above (A2:B8)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top