In column AI have a list of domain names with various TLDs eg .com .co .net etc. In Column B I'm wanting to put the annual renewal price.
I know this isn't the correct syntax, but I'm hoping someone could help me.
=IF(SEARCH(A2,".com"),9.00,(SEARCH(A2,".net"),10.50,SEARCH(A2,".co.uk"),5.00,"FALSE")
Alternatively if there are multiple TLDs with the same value, would it be possible to specify this somehow?
There are several hundred TLDs I'm only wanting to search for a handful, but using VLOOKUP could be away of me adding a comprehensive list of TLDs and being able to search them all.
This is how you would fix your function:
=IFERROR(IF(IFERROR(SEARCH(".com",A2),FALSE),9,IF(IFERROR(SEARCH(".net",A2),FALSE),10.5,IF(IFERROR(SEARCH(".co.uk",A2),FALSE),5,"NO MATCH"))),"NO MATCH")
But the best option would be to use a wildcard lookup function a la barry houdini. There was actually a challenge contest related to this a while ago:
http://www.mrexcel.com/pc18.shtml
Here is an example:
=VLOOKUP(LOOKUP(32768,SEARCH(D$2:D$4,A2),D$2:D$4),$D$2:$E$4,2,FALSE)
This way you can avoid an infinitely long compound if-statement that checks the innumerable url domain names.
You want to create a lookup table for your TLDs and prices
.com | $10
.net | $5
.org | $5
Then you want to split your domains so you have the TLD in a separate column. If all your TLDs are three letters eg .net, .com, you can get them into a separate column like this:
=RIGHT(A1, 4)
If they are not just three letter TLDs, it's a bit more tricky.
Once you split your TLD into a separate column, use the VLOOKUP
function to look up the price for each TLD.
=VLOOKUP(tld_to_lookup, range_of_lookup_table, 2, FALSE)
The "2" in that formula is a reference to the second column in your lookup table above and "FALSE" says we don't want an approximate match, we want an exact match.
此数组公式可用于在任何其他任意字符串中查找任何任意字符串:
{=VLOOKUP(MID(cellBeingSearched,MIN(IFERROR(FIND(FirstColumnOfTable,A2),1000)),1000),WholeTable,2,FALSE)}
The answer @Stepan1010 posted is correct for excel.
It's a form of "array function" (searching a "table array"). Apple Numbers can't do array functions the way Excel can
So for those of you wanting a solution to the issue I was faced with, the following formula works in Both Excel for PC and Mac and Number for Mac.
=VLOOKUP(RIGHT(A2,LEN(A2)-SEARCH(".",A2)+1),C$2:D$4,2,FALSE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.