I have 3 sheets S1, S2, and S3 that I use on a 4th sheet that I use formulas to index and match IP addresses. S1 contains a mapping of NAT IPs for the client's A private subnet and S2contains a mapping of NAT IPs for the client's B private subnet i.e. (A) 10.1.1.1 (B2) 100.
I use S4 A2 - AX and input an IP that I want to look i.e 100.100.1.1, B2 will Index and match S3 and return the IP in question which tells me it exists in the database. then in C2, I want to use the value in B2 and index and match the proper sheet based on the 1st & 2nd octet of the IP... i.e if the 1st two octets start with 100.100.x.x then index and match S1 if the IP starts with 100.200. then look it up on S2 and if the IP starts with 10.x.x.x I want to look it up on the sheets and return its mapped NAT IP if it exists.
=IFS(LEFT(A2,8)="100.100.",INDEX('S1.csv'!$C:$C,MATCH(B2,'S1.csv'!$F:$F,0)),LEFT(A2,8)="100.200.",INDEX('S2.csv'!$C:$C,MATCH(B2,'S2.csv'!$F:$F,0)))
I am stuck on how to do these check those three conditions :( I tried IFS, IFERROR, OR, AND but still not able to figure it out. any help suggestions are highly appreciated.
what I am trying to accomplish here is:
check if cellA2 contains an IP of 100.100.x.x, if true lookup its nat address. if the IP starts with 100.200 return its real IP from the client's B sheet and if it is not 100.100.x.x nor 100.200.x.x and it starts with 10. or 65 etc.. return its NAT'd IP.
thank you in advance
I think you should nest the if statements for each case. Another tip: you could use the LET function to capture the LEFT 7 characters of the IP address and store it in a variable (in my case called domain):
=LET(domain,LEFT(A2,7),IF(domain="100.100",[do the index/match in S1],IF(domain="100.200",[do the index/match in S2],[do the index/match in S3])))
Related
So I have the following text:
192.1.2.30,192.1.2.39
192.1.2.32,192.1.2.3
using this formula
=COUNTIF(A:A,"*"&D1&"*")
this checks if the IP address is in the text. Which is the issue. It's a wild card search
D1 - D4
192.1.2.30 >> result >> 1 >> CORRECT
192.1.2.39 >> result >> 1 >> CORRECT
192.1.2.3 >> result >> 2 >> **INCORRECT** >> should be 1
192.1.2.32 >> result >> 1 >> CORRECT
192.1.2.3 shows as 2 because 192.1.2.3 is part of 192.1.2.30.
Is there a way exclude the incorrect IP as matching twice?
If your version supports TEXTJOIN() then could try-
=SUM(--(FILTERXML("<t><s>"&SUBSTITUTE(TEXTJOIN("</s><s>",TRUE,$A$1:$A$10),",","</s><s>")&"</s></t>","//s")=C1))
=COUNTIF(A:A,"*"&D1&"*") counts the total number of rows where D1 is a substring.
You want to get only a substring with full IP Address, that is you need to differentiate a full IP address.
Your input is separated by commas so we can utilize that. We are sure it's an IP if it is between two commas.
=COUNTIF(A:A,"*,"&D1&",*")
However the first and last IP addresses does not adhere to this. I would just add commas in front and end of input so it becomes consistent for our first and last IP via:
=","&A1&","
Assuming that all search patterns start with 192, there are three main ways of counting the matches of a string exactly:
(1) Countif with wildcards:
=COUNTIF(A$2:A$9,"*"&C2&",*")+COUNTIF(A$2:A$9,"*"&C2)
(2) Find with isnumber and sum (or sumproduct):
=SUM(--ISNUMBER(FIND(C2&",",A$2:A$9&",")))
(3) Substitute with len and sum:
=SUM((LEN(A$2:A$9&",")-LEN(SUBSTITUTE(A$2:A$9&",",C2&",","")))/LEN(C2&","))
The results are as follows:
Countif counts once per row as long as the same IP address can't be repeated in the same row.
Find only counts once per row.
Substitute counts multiple occurrences per row.
If the above assumption doesn't hold (e.g. you want to search for 92.1.2.3 and still demand an exact match), then you would have the following:
(1) Using countif to count the number of lines containing the string, it's necessary to consider separate cases for when the string is on its own, at the start of a line, in the middle of a line, or at the end of a line. Assumes as before that there is no more than one occurrence per line:
=COUNTIF(A$2:A$9,C2)+COUNTIF(A$2:A$9,C2&",*")+COUNTIF(A$2:A$9,"*,"&C2&",*")+COUNTIF(A$2:A$9,"*,"&C2)
(2) Find still counts the number of lines containing at least one occurrence if the string is fully delimited:
=SUM(--ISNUMBER(FIND(","&C2&",",","&A$2:A$9&",")))
(3) I don't think you can count all occurrences including multiple occurrences in the same line with substitute in the general case because it becomes recursive (not without VBA or, if you had Excel 365, a lambda, but in that case you would use Filterxml anyway).
I am trying to add data validation for ip address in my cell. The Ip address should be from 0.0.0.0 to 256.256.256.256. To check valid Ip address i am trying to check following conditions:
1.there should be only three dots
2.length of digits should be from 4 to 12.
3.not any digit should be more than 256 or less than 0.
4.it should not take any blanks in between
I am trying through data>data validation>custom>formula>
1.=AND((LEN(C8)-LEN(SUBSTITUTE(C8,".","")))=3,ISNUMBER(SUBSTITUTE(C8,".","")+0))
2.=AND(LEN(C8)-LEN(SUBSTITUTE(C8,".",""))=3,--LEFT(C8,FIND(".",C8)-1)<224,--LEFT(C8,FIND(".",C8)-1)>0,--MID(SUBSTITUTE(C8,"."," "),6,5)<256,--MID(SUBSTITUTE(C8,"."," "),15,7)<256,--MID(SUBSTITUTE(C8,"."," "),22,10)<256)
But my all conditions are not getting satisfied from it.
Please let me know how to add data validation for IP through data validation or conditional formatting.
As a custom validation rule, try:
=AND(COUNT(FILTERXML("<t><s>"&SUBSTITUTE(A1,".","</s><s>")&"</s></t>","//s[.*1>-1][.*1<256]"))=4,LEN(A1)-LEN(SUBSTITUTE(A1,".",""))=3)
Where we use FILTERXML to split the string on dots and through XPATH we return those numeric elements ranging from 0-255. Then COUNT will check if there are just 4 elements returned.
The AND is there because we also need to ensure that there are only three dots.
Please do note that using FILTERXML requires Excel 2013 or higher (Excluding Excel Online or Mac).
I'm trying to work out whether an ID and ip address is for a specific company.
In the list of IP addresses there are 2 that I need to look for (192.4.5.6 & 192.4.5.9) out of 10 different ip addresses.
If it's a certain ID number (GH113) I want it to print out "yes" for the 2 ip addresses listed above and if it has that same ID but a different ip address I want it to print out "no". If none match the ID or IP address I want it to print out "N/A".
I've got the following formula which is only printing "yes" and "no" but not "N/A" but it's also printing out "FALSE" and I'm not sure why:
=IF(B2="GH113",IF(F2="192.4.5.6","No",IF(B2="GH113",IF(F2="192.4.5.9","No","Yes"),"N/A")))
B2 is the ID column and GH113 is the company ID I am looking for.
F2 refers to the IP addresses column and the ip addresses listed above are the ones I am searching for.
Any help on where I am going wrong would be greatly appreciated.
Thanks
=IF(B2="GH113", IF(OR(F2="192.4.5.6", F2="192.4.5.9"), "yes", "no"), "N/A")
Hi guys having a bit of a problem with the below formula,
What it is intended to do is search a customers email address to see if the customer name is contained in the domain of said email address, the name is split into three parts as seen in the formula below.
My problem is when one of the customer name cells is blank the formula evaluates as true (E-mail address okay), I've tried using ISBLANK but I can't get it to function properly that code is also displayed below.
=IF(G4="","No E-mail Address",IF(L4&K4&J4="","No Customer name on file",IF(ISNUMBER(SEARCH("#"&J4,G4)),"E-mail Address OK",IF(ISNUMBER(SEARCH("#"&K4,G4)),"E-mail Address OK",IF(ISNUMBER(SEARCH("#"&L4,$G4)),"Email Address okay",("E-mail Address NOT OK"))))))
=IF(G4="","No E-mail Address",IF(L4&K4&J4="","No Customer name on file",IF(ISBLANK*ISNUMBER(SEARCH("#"&J4,G4))),"E-mail Address OK",IF(ISBLANK(ISNUMBER(SEARCH("#"&K4,G4))),"E-mail Address OK",IF(ISBLANK(ISNUMBER(SEARCH("#"&L4,$G4))),"Email address okay",("E-mail Address NOT OK"))))))
Your formula evaluates to true because ISBLANK is set as a positive condition. You'll need to change it to NOT(ISBLANK...).
Try this version - it checks all three name cells in one go and the added (J4:L4<>"") [range not blank] part stops you getting "false positives"
=IF(G4="","No E-mail Address",IF(L4&K4&J4="","No Customer name on file",IF(ISNA(LOOKUP(2^15,SEARCH("#"&J4:L4,G4)/(J4:L4<>""))),"(Email address NOT OK)","Email address okay")))
I have two lists of street addresses that have a combination of street numbers and names in one cell. One list is a key, if you will, of how the addresses are labeled in our company, and the other list is all of the addresses that customers used to get a package to us. For example![Address Key][1]
is the correct address format. The other list has errors within the address because there may be errors with order, fat fingered street numbers, or spelling errors of the street names. I'd like to create a formula or find a way that looks for any portion of the second list, and have it return a "yes" or "no" if it is an address in the address key. The second list that I need to lookup with is below.![enter image description here][2]
You can see that the addresses that the customers enter do not match how we label our addresses. Hopefully there is a way for me to look up any part of the address that they entered against our key, and have it return a value that is associated with each address in the key. For example, the first address is location 100. Even though the customer list doesn't have that address entered correctly, i'm hopping it can find a part of the address they entered in our list.
Thanks,
Jay
You can try using a Vlookup with a 'TRUE' parameter in the RangeLookup argument. That way the Vlookup will return an approximate match against your company list. You may need to reformat the data a bit (e.g. concatenate house number and street name together) and do some iterations to get the final result that you need. You haven't added any screen shots so I can't see the exact format of your data.