Help with if function to deleted characters if met criteria

Copper Contributor

Hi guys,

 

I'm working with a data set where have a lot of website links. The thing is that most of the links are personalized. For example https:// thisisatest/testing?wvideo=9gpspqefxd


What I need is to delete all the characters after the question mark (
?) so that I would look like this:

https:// thisisatest/testing

 

I've already figured out the function to delete that which is =LEFT(A1,FIND("?",A1)-1). However, in the list, of websites, there are also links that don't have the question mark (?), therefore, when I apply the formula to all cells, the ones that don't have the (?) show me as #VALUE! 

 

I thought of using an IF function but I've been struggling to make it work. This is the formula:

=IF(M2="?","(LEFT(M2,FIND("?",M2)-1))","M2")

 

It is supposed to find in A1 the character (?), and after the condition is met, it should do the rest but doesn't work.

 

I appreciate it if you can help me.

 

Thank you!

 

1 Reply

@RubenZh 

 

here is a link as info for this function

SEARCH, SEARCHB functions

https://support.microsoft.com/en-gb/office/search-searchb-functions-9ab04538-0e55-4719-a72e-b6f54513... 

 

or....

 

Start menu
Search and select menu
From this menu you can select Search for cells and, if necessary, change text or formulas.

 

I would be happy to find out if I could help.

 

Nikolino

I know I don't know anything (Socrates)