Help to extract parameter from URL in Excel

Soldato
Joined
19 Mar 2012
Posts
6,586
Code:
=MID(E6,FIND("&profile=",E6,1)+9,IFERROR(FIND("&",E6,FIND("&profile=",E6,1)+9)-FIND("&profile=",E6,1)-9,LEN(E6)-FIND("&profile=",E6,1)-9))

This works for all the examples you have given.

It works on the basis that the bit you want to extract always has &profile= directly in front of it, which it uses to tell the formula where to start picking the text from.

It also relies on either the URL ending after the bit you want to extract, or there being a & directly after it.

Given those conditions, it should work.
 
Associate
Joined
24 Jun 2008
Posts
1,168
Here is my go, like wesimmo's code.
Code:
=IFERROR(MID(A1,SEARCH("&profile=",A1)+9,SEARCH("&",MID(A1,SEARCH("&profile=",A1)+9,20))-1),MID(A1,SEARCH("&profile=",A1)+9,20))
remember find is case sensitive.
I picked 20 characters for the string returned by search just because I didn't want it to go to the end if it didn't need to.

I'm also relying on the fact that if it's not got a & it will be the last thing in the string.
 
Last edited:
Back
Top Bottom