Search code examples
excelimagehyperlinkpasting

How to paste only the first url from a list of urls of images seperated with a comma "," to another cell in Excel


I am using a .csv excel table for product images for woocommerce store. I want to paste the images into a cell next to the URLs of the images. I am using the function =IMAGE(G2;2) to select the URL and just paste the image from it on the cell next to it.

But some of my cells contain multiple images, for example,/images/image1.jpg, /images/image2.jpg, /images/image3.jpg and I can't do select them and paste them the same way.

How can I select only one of the images and paste it again on the next cell?


Solution

  • If you just want to find the first URL on cells with several URLS separated by commas, you can use:

    LEFT(A1;SEARCH(",";A1)-1)

    enter image description here

    The formula works this way:

    1. SEARCH(",";A1) will find the position of th first comma
    2. LEFT(A1;SEARCH(",";A1)-1) will extract, starting by left, all chars until position of comma minus 1

    You can combine this with an IFERROR in case there is no comma (I guess that means there is only 1 single URL in the cell).

    In the image above in cell B2 the formula I've used is:

    =IFERROR(LEFT(A2;SEARCH(",";A2)-1);A2)

    If there is no comma, the formula will return the value inside cell. If there is a comma, then it will return all chars starting by left until comma position (minus 1).

    Hope you can adapt this to your needs.

    NOTE: IMAGE function is a Google Sheet function, not Excel.

    GS FUNCTION IMAGE

    Notice that, even if they are really similar, Google Sheets and Excel are two different apps, so not all works in both apps. Next time you ask something you want to apply to Google Sheets, use the right tag, please