Un-Shorten URL

Nanogirl21

Active Member
Joined
Nov 19, 2013
Messages
331
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.
[TABLE="width: 125"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: left"]http://goo.gl/QIp7xJ[/TD]
[/TR]
[TR]
[TD="align: left"]http://goo.gl/Hga4Dw[/TD]
[/TR]
</tbody>[/TABLE]


Thank you.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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,223,842
Messages
6,174,981
Members
452,597
Latest member
Barny72

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