Here in the Natural Search department we use Excel. A lot. And frequently we are taking data from the web (such as from the rather good Open Site Explorer) and manhandling it in order to make more sense of it. As part of this process, it’s often helpful to be able to quickly pull out the domain portion of a URL. For example, let’s say you have a list of URLs like this:
- http://www.example.com/
- http://www.icrossing.co.uk/file1.html
- http://www.icrossing.co.uk/file2.html
- http://example.com/another_file.html
- http://www.acompletelydifferentdomain.com/
You might find yourself in a position where want to take this list and reduce it to just the domain portions like this:
- example.com
- icrossing.co.uk
- icrossing.co.uk
- example.com
- acompletelydifferentdomain.com
It’s possible to use an Excel formula to do this. Here’s one I found by searching:
=IF(LEFT(LEFT(SUBSTITUTE(A1,”http://”,”"),FIND(“/”,SUBSTITUTE(A1,”http://”,”")&”/”)-1),4)=”www.”,MID(LEFT(SUBSTITUTE(A1,”http://”,”"),FIND(“/”,SUBSTITUTE(A1,”http://”,”")&”/”)-1),5,256),LEFT(SUBSTITUTE(A1,”http://”,”"),FIND(“/”,SUBSTITUTE(A1,”http://”,”")&”/”)-1))
This is fine, but as you can see the formula is rather long and combining this with any further functions would be a real headache. To try to solve this, I wrote an add-In for Excel that adds a handy function to perform this step (along with a few others).


















