+ Reply to Thread
Results 1 to 11 of 11

shortening a URL

  1. #1
    Registered User
    Join Date
    06-01-2007
    Posts
    9

    shortening a URL

    Hello!

    I have a very long column (almost 3000 cells) of URLs. I would like to replace them in the second column with shortened versions, basically cut them at the fourth slash.

    Let me illustrate:

    www.plant.edu/wm/mail/window/apple/seed

    would turn into

    www.plant.edu/wm/mail/window

    Could you tell me how can I used functions in Excel to do it? I am not very advanced when it comes to Excel and I need help. Thank you very much.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Does this help

    =HYPERLINK(LEFT(A1,FIND("^",SUBSTITUTE(A1,"/","^",4))-1))

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-10-2005
    Location
    Finland
    Posts
    10

    One solution is Macro (VBA)

    I don't see any functions to solve this. So I made little VBA-code to handle it.
    Long URLs in Column A begins with row 1. Fixed URLs will be placed in Column B. Here is the code for that. Hope it's helping you.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 06-01-2007 at 05:19 AM.

  4. #4
    Registered User
    Join Date
    06-01-2007
    Posts
    9

    Thank you

    Thank you both of you for the fast posts.

    I tried to enter the formula, VBA Noob, but it does not seem to be working. I get error message.

    I will try your solutions on Monday, Escelien. I am off work now and I want to solve the problem beginning of next week.

    Thank you very much again! It is great to see such fast responses.

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Here's an example

    VBA Noob
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-01-2007
    Posts
    9
    Thank you, VBA Noob. Unfortunately, I cannot open the file. Could you try posting it again?

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    If you have Windows XP, save the file to your PC and right-click on it and choose Explore. You'll then see the Excel file and can double-click to open it.

    If you don't have Windows XP, you'll need a zip utility to extract the Excel file from the .zip file (such as WinZip, WinRAR, PKZip, etc.)

  8. #8
    Registered User
    Join Date
    06-01-2007
    Posts
    9
    Thank you, Paul! That was very helpful. Unfortunately, I still get value error when I input that in Excel

  9. #9
    Registered User
    Join Date
    06-01-2007
    Posts
    9
    Solved the problem! The formula worked, thank you so much. I would have never done it if not for your help.

  10. #10
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Good to hear you got it sorted

    VBA Noob

  11. #11
    Registered User
    Join Date
    06-01-2007
    Posts
    9
    I got a new twist to the problem. How can I get the formula to return everything up to the fourth slash? Right now, whenever the URL is shorter than 4 slashes, I get error value.

    Thanks a lot for helping out!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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