Excel: Remove everything after ? in a url

Try

=IF(LEN(SUBSTITUTE(A1,"?",""))=LEN(A1),A1,LEFT(A1,FIND("?",A1)-1))

to

  • Cater for the ? not appearing in A1 without raising an error
  • Properly truncating the string to http://www.site.com/index.php .... your accepted answer doesnt adjust for the position of ? and it will return http://www.site.com/index.php?

You may try something like this:

=LEFT(A1,FIND("?",A1))

Here A1 is your url


If you want to return another hyperlink, but only cosisting of everything before the question mark, you could use the following formula, having you URL in cell A1.

=HYPERLINK(LEFT(A1,FIND("?",A1,1)-1))