Encode URL parameters in MS Excel 2013 and above

Function ENCODEURL() is good for encoding URL component but requires extra work to encode a string to be used in a query part of a URL.

More specifically ENCODEURL() encodes spaces as %20 instead of + character. This can be solved by substituting %20 with + in a string produced by ENCODEURL().

Example #1: A + B

=CONCATENATE("https://www.google.com/search?q=",SUBSTITUTE(ENCODEURL("A + B"),"%20","+"))

Output:

https://www.google.com/search?q=A+%2B+B

Example #2: Unicode support

=CONCATENATE("https://www.google.com/search?q=",SUBSTITUTE(ENCODEURL("Привет мир!"),"%20","+"))

Output:

https://www.google.com/search?q=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82+%D0%BC%D0%B8%D1%80%21

Leave a Reply

(optional)

This site uses Akismet to reduce spam. Learn how your comment data is processed.