+ Reply to Thread
Results 1 to 21 of 21

Is there a formula to decode URL's?

  1. #1
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Is there a formula to decode URL's?

    Is there a formula i can use to decode URL's back to their original form?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is there a formula to decode URL's?

    Hi,

    Can you clarify please. An example or three of URLs and the results you want after 'decoding' them.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Is there a formula to decode URL's?

    No, you'll need vba

  4. #4
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: Is there a formula to decode URL's?

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Can you clarify please. An example or three of URLs and the results you want after 'decoding' them.
    An example would be this, top line is encoded and bottom line is decoded.

    cid=up1hdrs459&mkwid=sMeHM1DPA_dc|pcrid|41715939743|pkw|perfume%20bcbg%20maxzaria|pmt|e|cmpn|205_Perfumes+By_BCBG%3EBrand_Search|&lp=https%3A%2F%2Fwww.perfumes.com%2Fmembership&gclid=E9Oji574CFahaMLzMAFg

    cid=up1hdrs459&mkwid=sMeHM1DPA_dc|pcrid|41715939743|pkw|perfume bcbg maxzaria|pmt|e|cmpn|205_Perfumes By_BCBG>Brand_Search|&lp=https://www.perfumes.com/membership&gclid=E9Oji574CFahaMLzMAFg

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is there a formula to decode URL's?

    Hi,

    When I asked for an example I should of course have specifically said 'in a workbook'.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Is there a formula to decode URL's?

    Please Login or Register  to view this content.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is there a formula to decode URL's?

    Hi,

    Try this

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Is there a formula to decode URL's?

    Here's the list if you fancy a formula:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: Is there a formula to decode URL's?

    Quote Originally Posted by Kyle123 View Post
    Here's the list if you fancy a formula:
    Please Login or Register  to view this content.
    Im not good with VBA so maybe im doing something wronmg. I created a macro with the first code you sent me but it does nothing am i missing this part of the code? Also I only need to decode a column of URL's not the entire workbook. Sorry if i sound dumb .

    Richard the word By is not a constant in the URL strings.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Is there a formula to decode URL's?

    No you didn't miss anything. What have you actually done with the code posted?

    It should go something like this:
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To use the code, just use it as a normal function:
    PHP Code: 
    =UnEscapeUrl(A1

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is there a formula to decode URL's?

    Quote Originally Posted by mikey42979 View Post
    Im not good with VBA so maybe im doing something wronmg. I created a macro with the first code you sent me but it does nothing am i missing this part of the code? Also I only need to decode a column of URL's not the entire workbook. Sorry if i sound dumb .

    Richard the word By is not a constant in the URL strings.
    Hi,

    OK, in that case is it a two character string preceded by a '+' character. If so, or if there is some other characteristic that can be used to identify the variable string then this could easily be built in.

    Upload some example strings so that this can be tested.

  12. #12
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: Is there a formula to decode URL's?

    Quote Originally Posted by Kyle123 View Post
    No you didn't miss anything. What have you actually done with the code posted?

    It should go something like this:
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To use the code, just use it as a normal function:
    PHP Code: 
    =UnEscapeUrl(A1
    Woot this works almost like a charm but its not removing the + symbols (Perfumes+By) should be (Perfumes By), how can i fix this thanks sooo much.

  13. #13
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: Is there a formula to decode URL's?

    Anyone know why this doesnt decode the +?

  14. #14
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: Is there a formula to decode URL's?

    Never mind i found one that works online for those of you looking for this fix. This one will encode or decode, once you enter the macro you just type =urldecode in a cell and point to the cell containing the URL you need to decode.

    Public Function URLEncode(StringToEncode As String, Optional _
    UsePlusRatherThanHexForSpace As Boolean = False) As String

    Dim TempAns As String
    Dim CurChr As Integer
    CurChr = 1
    Do Until CurChr - 1 = Len(StringToEncode)
    Select Case Asc(Mid(StringToEncode, CurChr, 1))
    Case 48 To 57, 65 To 90, 97 To 122
    TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
    Case 32
    If UsePlusRatherThanHexForSpace = True Then
    TempAns = TempAns & "+"
    Else
    TempAns = TempAns & "%" & Hex(32)
    End If
    Case Else
    TempAns = TempAns & "%" & _
    Format(Hex(Asc(Mid(StringToEncode, _
    CurChr, 1))), "00")
    End Select

    CurChr = CurChr + 1
    Loop

    URLEncode = TempAns
    End Function


    Public Function URLDecode(StringToDecode As String) As String

    Dim TempAns As String
    Dim CurChr As Integer

    CurChr = 1

    Do Until CurChr - 1 = Len(StringToDecode)
    Select Case Mid(StringToDecode, CurChr, 1)
    Case "+"
    TempAns = TempAns & " "
    Case "%"
    TempAns = TempAns & Chr(Val("&h" & _
    Mid(StringToDecode, CurChr + 1, 2)))
    CurChr = CurChr + 2
    Case Else
    TempAns = TempAns & Mid(StringToDecode, CurChr, 1)
    End Select

    CurChr = CurChr + 1
    Loop

    URLDecode = TempAns
    End Function

  15. #15
    Registered User
    Join Date
    01-25-2019
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    5

    Re: Is there a formula to decode URL's?

    How I do it to UTF-8?
    Last edited by fagnerdin; 01-25-2019 at 09:58 AM.

  16. #16
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Is there a formula to decode URL's?

    Hi fagnerdin, welcome to the forum! Please check the forum rules especially #4 about posting an issue on another thread. Please start your own post as it will be better to give you specific answers for your issue.
    Thanks.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  17. #17
    Registered User
    Join Date
    01-25-2019
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    5

    Re: Is there a formula to decode URL's?

    hi!

    Sorry...

    I found the solution for my question, can I write this on the same topic?

  18. #18
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Is there a formula to decode URL's?

    it would still be best to start your own post with an appropriate title then post the solution and mark it as solved, you can even past this link in if you think it helps.
    The reason is if someone else has a similar issue to yours it will then show up on a search and the solution will be available. Some people limit their searches on this forum by date and this, though similar might not show up on their search.
    By the way, my first post to this site was also on someone else's similar problem and I was promptly informed.
    so it isn't something to be concerned about, quite a few of us at times don't adhere to the rules - usually by accident.

  19. #19
    Registered User
    Join Date
    01-25-2019
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    5

    Re: Is there a formula to decode URL's?

    so, I created this thread:
    excelforum.com/excel-formulas-and-functions/1261747-is-there-a-formula-to-decode-urls-and-having-outputting-in-utf-8-a.html
    that's the way?

  20. #20
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Is there a formula to decode URL's?

    yes. If you felt this thread had some value to yours you could post the url from this post on that one.
    but I saw your post and that is the way.

  21. #21
    Registered User
    Join Date
    12-10-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    1

    Re: Is there a formula to decode URL's?

    You can do it without VBA using array formulas. If A1 is the cell to be decoded, enter this formula, and then press Ctrl-Shift-Enter:
    Please Login or Register  to view this content.
    It won't work if you don't Ctrl-Shift-Enter. The URL string in A1 must be valid and have no * characters (otherwise, consider changing the expression above). For example, a sequence like %A% will make the expression not work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Scramble Text and Decode
    By unclejemima in forum Excel General
    Replies: 6
    Last Post: 08-16-2015, 09:14 AM
  2. Replies: 4
    Last Post: 06-12-2013, 10:28 AM
  3. help needed to 'decode' some excel formulae
    By mcenteeg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-16-2011, 01:08 PM
  4. [SOLVED] serial number decode
    By chiuinggum in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-13-2006, 04:20 AM
  5. Decode MP3 ID3v2 and WMA tag info
    By Tom D in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2005, 10:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1