ferrarista
asked on
Excel - function to find subnet match
Hi guys.
I have a worksheet with a list of subnets in a CIDR format, example 192.168.0.15/24.
On another worksheet I have a list of servers, along with their respective IP address, say 192.168.0.10.
What kind of formula would allow me to compare the value of each server's IP address and match it with the relevant subnet ?
Thanks for any help.
I have a worksheet with a list of subnets in a CIDR format, example 192.168.0.15/24.
On another worksheet I have a list of servers, along with their respective IP address, say 192.168.0.10.
What kind of formula would allow me to compare the value of each server's IP address and match it with the relevant subnet ?
Thanks for any help.
That won't work on anything other than a 24bit subnet mask. Have a look at the macro in this post for solution for all masks
https://www.experts-exchange.com/questions/28993108/Vlookup-nonexact-IP-address-match.html
https://www.experts-exchange.com/questions/28993108/Vlookup-nonexact-IP-address-match.html
Shaun, sorry to disagree with you. It works. Download the excel attached and test.
This functions created don't have any consideration on the mask but the strictly string structure of any class of IP.
This functions created don't have any consideration on the mask but the strictly string structure of any class of IP.
Is IP 192.168.0.130 in 192.168.0.0/25?
That is a sample data on the excel sheet.
I m working on a basis of this question, which is excel worksheet.
Your network calculation of course is correct but we are asked for reference which I believe is as simple as the excel.
I m working on a basis of this question, which is excel worksheet.
Your network calculation of course is correct but we are asked for reference which I believe is as simple as the excel.
Then see the link I posted which is a simple Excel Macro that works out subnet masks correctly.
And if I may, your sheet included the sample data with a 28bit mask which prompted my post
See attached
TestIP.xlsm
And if I may, your sheet included the sample data with a 28bit mask which prompted my post
See attached
TestIP.xlsm
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Created two worksheets. One with subnet list and other with the server list.
Functions one. To get a potion of sub string in a subset set. I used a helper column on the server list which even when you hide still works fine.
=IFERROR(LEFT(A2,LEN(A2)-F
Function two. Used the Vlookup to utilise results of function one.
=VLOOKUP(C3&"*",SUBNETS!$A
I wont explain much on but i would like you to refer to the attached excel and rate accordingly.
sev_subnet.xlsx