Extract URL's from a Cell of Text in Excel - excel

I have an Excel document with a column that contains cells of text (small paragraphs usually). I'd like to find a way (preferably a formula) to extract any url's those cells by row and add them to another column.
I've been messing around with MID and FIND quite a bit and can very easily get to the begginning of those URLs by searching for "http", but I can't figure out how to then find the length of the url so I can grab it.
Really looking forward to any help anyone could offer. It's driving me nuts!

To take into account the URL happening at the end of a string you'll need to add some error handling.
This should work for both mid string and end of string:
=MID(C11,FIND("http",C11),IFERROR(FIND(" ",C11,FIND("http",C11))-1,LEN(C11))-FIND("http",C11)+1)

Ok, I think I've got it working. Check it out:
=MID(C11,FIND("http",C11),(FIND(" ",C11,FIND("http",C11))-FIND("http",C11))-4)

Once you've identified the start position of the URL look for the first space after that, should be the end of the URL.

Your most likely option is to make sure you can rely on the URLs being formed the same way. Like, always start with "http" and always end with "/" or a ".com". Then you can do formulas to find the index start, index end, and grab the MID for everything in between.
It should look like this:
=FIND("http",D3)
returns the location of the first part.
=FIND(".com",D3)
returns the location of the end
=MID(D3,D9,D10-D9+4)
Returns the string provided by the start to the end+4 (to allow for those 4 characters)

Related

Remove everything after hyphen in hyphenated names in Excel using Formula

I am in charge of adding new employees to our speech recognition and gamification systems.
When I get a batch of tickets, I compile a bunch of data into a spreadsheet that I then reference when adding those users to the systems (Which unfortunately do not have a JSON/CSV upload option or anything similar)
To save some time with compiling, I've started exporting a bunch of data from our database and our HR management system into that sheet, and then using the new employee's email to XLOOKUP all the other data fields.
For one of our systems, it has a strict character limit, and the format for the username is "cde\firstname.lastname". This is no problem to CONCATENATE normally, but it has a strict character limit, so if the user has a hyphenated last name, I will basically dump everything after the hyphen.
At first I tried a simple formula using a combination of LEFT and FIND -1 to find the hyphen, and then take everything to the left of it. This obviously doesn't end up working because I get a #VALUE! for anyone without a hyphen in their last name.
I tried using IFERROR to say "OK try to return the last name without a hyphen, otherwise just return the last name", but for some reason when I put the reference in the Return_If_Error portion, it doesn't recognize it as a reference.
So I am looking for a formula that will work with a LOOKUP'd value and only give me what's before a hyphen, but otherwise will still just give me the last name.
The baseline formula I have, that just looks up and concatenates the first and last into the "cde\firstname.lastname" is:
=CONCATENATE("cde\",LOWER(XLOOKUP(G578,Sheet4!M:M,Sheet4!B:B)),".",LOWER(XLOOKUP(G578,Sheet4!M:M,Sheet4!C:C)))
To expand on the comments, you've got the right idea, just use an IF statement for testing if the string contains "-", then use the normal string functions like FIND, LEFT, etc. to pick out the things you want.
For example:
="cde/"&
LEFT(H1,FIND(".",H1)-1)&
IF(ISNUMBER(FIND("-",H1)),MID(H1,FIND(".",H1),FIND("-",H1)-FIND(".",H1)),
MID(H1,FIND(".",H1),FIND("#",H1)-FIND(".",H1)))

Excel formula that does both right and replace in one cell?

I have a bunch of URLs in a column like below:
https://www.example.com/xx/yy/product-name-could-be-30238543/
https://www.example.com/xx/yy/product-name-might-70293274/
https://www.example.com/xx/yy/product-name-may-40242653/
I wish to extract the ID's from the id but not with the last / in them. The right function gives me below:
40242653/ but i wish to get rid of the ID's too within the same function so can someone suggest a way?
Otherwise, i have to use another replace function separately to get rid of ending trailing slashes.
Thanks,
If all the IDs have 8 numerals, then you can use:
=LEFT(RIGHT(A1,9),8)
If they have more or less than 8 numerals, then ignore this answer.
I have found this to be easier to use (It extracts everything after the last occurrence of - in them.
SUBSTITUTE(RIGHT(A1;LEN(A1)-FIND("#";SUBSTITUTE(A1;"-";"#";(LEN(A1)-LEN(SUBSTITUTE(A1;"-";"")))/LEN("\"))));"/";"";1)

Attempting to extract one of two possible words from a text string if matches a criteria, or input the string in it's entirety

I'm trying to bring back one of two possible words (Local or National) from a text string, and if neither of these words are in the text string, then bring back the string in the whole cell
The issue I have is that I can bring back either word when they appear, but I get an error when they do not
I'm currently using
=IFERROR(IF(SEARCH("*local*",B2,1),"Local"),IF(SEARCH("*national*",B2,1),"National"))
However this obviously this doesn't bring back if the words not exist
I'm sure it's easy and I'm missing something, but I just cannot figure it out. any help would be great
Cheers all
You can use:
Formula in B1:
=IF(ISNUMBER(SEARCH("*local*",A1)),"Local",IF(ISNUMBER(SEARCH("*national*",A1)),"national",A1))
Drag down
Note:
Notice that your wildcards make it that even a string with 'international' in it will return 'national'. If this is not what you want, you should remove the wildcards.
You can also use INDEX/AGGREGATE:
=IFERROR(INDEX({"local","national"},AGGREGATE(15,7,ROW($1:$2)/(ISNUMBER(SEARCH({"local";"national"},A1))),1)),A1)
This will allow one to replace the both hard coded arrays with a range of cells that contain the outputs. If Local and National were in D1:D2 then you can use:
=IFERROR(INDEX($D:$D,AGGREGATE(15,7,ROW($D$1:$D$2)/(ISNUMBER(SEARCH($D$1:$D$2,A1))),1)),A1)
That way if the list gets bigger the formula does not.
I'd suggest regular expressions.
=IF(REGEXMATCH(A2,"(Local|National)"),REGEXEXTRACT(A2,"(Local|National)"),A2)

Extract Parameter from URL Excel

does anybody has an excel formula for me which just gives me back the clickid parameter? Unfortunately this parameter is not always at the same position so I can't fix it with character count. It should always be between &clickid= and &
https://app.appsflyer.com/id770725904?pid=website_adwords&c=C_DEU_billig&tl_rf=https%3A%2F%2Fwww.google.com%2F&tl_nw=g&tl_mt=e&clickid=EAIaIQobChMIj5zchvqs4AIVQamaCh06NQlOEAAYASACEgJhRPD_BwE&af_keywords=billig+telefonieren+nach+iran&af_c_id=1597316081&af_adset_id=60710335432&af_ad_type=1t1&af_adset=Iran&af_ad_id=303032652682
Well for sure a regular expression will be able to find this, but a rather simple formula could do the trick aswell. For example:
=MID(A1,FIND("clickid=",A1)+8,FIND("&",A1,FIND("clickid=",A1)+8)-(FIND("clickid=",A1)+8))
This will work but someone may have a tidier option ...
=LEFT(SUBSTITUTE(MID(A1,FIND("clickid",A1),1000),"clickid=", ""),FIND("&",SUBSTITUTE(MID(A1,FIND("clickid",A1),1000),"clickid=", ""))-1)
Throw your URL into cell A1 and test it out.

Subdomain to Subdirectory Formula in Excel

I am trying to convert 'http://city.example.com' to 'http://www.example.com/city' in an Excel sheet.
I have tried a multi-step approach to first TRIM or SUBSTITUTE the prefix then the suffix, but I'm in over my head.
Any help would be greatly appreciated. Thanks in advance!
Do heed the comment regarding formulating a proper question and posting what you've tried and what is going wrong.
Either way, assuming your domains are in column A and there is only a single subdomain:
=SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")&MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2))
Breaking it down into pieces:
FIND("//",A1,1)+2 will return the index of the start of the subdomain.
FIND(".",A1,1) will return the index of the first period, the end of the subdomain.
As such, the string from the start of the subdomain to the period will be the subdomain - since we're getting index's back we have to subtract them to get our MID length - FIND(".",A1,1)-(FIND("//",A1,1)+2)
Chaining those together, we can say we want to substitute whatever is from the // to the first period with www. - SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")
This now leaves us with the subdomain replaced with www, so we just need to append the subdomain now, which we already know how to get - it's the mid formula we just used:
MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)
As such, we concatenate our two formulas together to get the result.

Resources