Un-Shorten URL

Nanogirl21

Active Member
Joined
Nov 19, 2013
Messages
330
Office Version
  1. 365
Platform
  1. Windows
I have about 3,000 shorten URLS. They was converted using Goo.Gl by someone else. Is there a way in Excel that I can unshorten these URLS and populate the full link in a new cell? Cell A2, A3, A4 ect is where I would like to put the new full URL. There is a website (Unshorten any URL - unshort.me) that allows you to unshorten URLS. It’s a pain to go through 3,000 URLS and copying them over to and from the website manually. Is there a way to do this in excel? Macro maybe?

Here are two URL's for example.
http://goo.gl/QIp7xJ
http://goo.gl/Hga4Dw

<colgroup><col></colgroup><tbody>
</tbody>


Thank you.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I reckon this'll get you most of them (put it in a standard module):
Code:
Public Function unshorten(url As String) As String
    
    Static oRequest As Object
    
    Set oRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
    
    With oRequest
        .option(6) = True
        .option(12) = True
        .Open "HEAD", url, False
        .send
        unshorten = .option(1)
    End With
    
End Function

It's then used as a worksheet function:
PHP:
=Unshorten(A1)
 
Upvote 0
I reckon this'll get you most of them (put it in a standard module):
Code:
Public Function unshorten(url As String) As String
    
    Static oRequest As Object
    
    Set oRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
    
    With oRequest
        .option(6) = True
        .option(12) = True
        .Open "HEAD", url, False
        .send
        unshorten = .option(1)
    End With
    
End Function

It's then used as a worksheet function:
PHP:
=Unshorten(A1)

That worked perfectly! Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top