Home » excel » if cell contains .com or .co.uk – if statement in excel / google spreadsheets

if cell contains .com or .co.uk – if statement in excel / google spreadsheets

Posted by: admin May 14, 2020 Leave a comment

Questions:

Ive got a list of urls, Im trying to check if for each cell the the url contains .com OR .co.uk and if it does put the text TRUE into the result cell, this way i can filter the result column to find all the cells that contain .com or .co.uk as the top level domain of the url.

At the moment im trying to use

=IF(D2=".com","TRUE", "FALSE")

The issue Im having is to do with the first argument to check if the url contains .com OR .co.uk, at the moment its just checking if the whole url == .com.

How to&Answers:

You can use FIND:

=OR(ISNUMBER(FIND(".com",A1)),ISNUMBER(FIND(".co.uk",A1)))

enter image description here

Use ISNUMBER to swallow any #VALUE! errors.

Note that FIND does a case-sensitive search. For a case-insensitive search, use SEARCH instead.

Answer:

You could also use regexextract with an or “|” to give it both variations:

=if(isna(REGEXEXTRACT(A1,"\.com|\.co\.uk")),,true)