Formula for a cell that contains one of two things

MistyWind

New Member
Joined
Dec 29, 2020
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I'm looking for a formula that will help me add a value to help me categorize page type. Column 1 contains url paths and I'd like column 2 to contain either "Products" or "Content". If column A contains "/collections/" or contains "/products/" it could be classified as "Products" in column B. If neither of these are detected, then column B would be populated as "Content". Thanks for any help.

PagePage Type
/collections/back-packsProducts
/faqContent
/collections/tentsProducts
/products/product-aProducts
/collections/cookingProducts
/products/product-bProducts
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
how about in B2 and copy down
=IF(A2="","",IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content"))

I have put in C2 - so you can compare

Book4
ABC
1PagePage Type
2/collections/back-packsProductsProducts
3/faqContentContent
4/collections/tentsProductsProducts
5/products/product-aProductsProducts
6/collections/cookingProductsProducts
7/products/product-bProductsProducts
8 
9 
10 
Sheet1
Cell Formulas
RangeFormula
C2:C10C2=IF(A2="","",IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content"))
 
Upvote 1
One option:

Code:
=IF(OR(ISNUMBER(SEARCH("/collections/",A2)),ISNUMBER(SEARCH("/products/",A2))),"Products","Content")
 
Upvote 1
Solution
how about in B2 and copy down
=IF(A2="","",IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content"))

I have put in C2 - so you can compare

Book4
ABC
1PagePage Type
2/collections/back-packsProductsProducts
3/faqContentContent
4/collections/tentsProductsProducts
5/products/product-aProductsProducts
6/collections/cookingProductsProducts
7/products/product-bProductsProducts
8 
9 
10 
Sheet1
Cell Formulas
RangeFormula
C2:C10C2=IF(A2="","",IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content"))
This worked great for me. Because I'm new to formulas, can you explain to me the use of "","" at the front of the formula and also why the use of "1"?
 
Upvote 0
One option:

Code:
=IF(OR(ISNUMBER(SEARCH("/collections/",A2)),ISNUMBER(SEARCH("/products/",A2))),"Products","Content")
This is great. Looks to be what I was trying to put together but I had a hard time figuring out how to add two different possibilities.
 
Upvote 0
if you copy the formula down the column as many rows as you like - there is a chance that it will probably find cells in column A that are blank
as i have shown

if a row is blank then it does not contain Product or collection and so false
in which case for blank cells in column A - it will be false and return Content - when in fact you have no data entered

you can see the difference in column C / D

Book4
ABCD
1PagePage Typewith ""without ""
2/collections/back-packsProductsProductsProducts
3/faqContentContentContent
4/collections/tentsProductsProductsProducts
5/products/product-aProductsProductsProducts
6/collections/cookingProductsProductsProducts
7/products/product-bProductsProductsProducts
8 Content
9 Content
10 Content
11 Content
12 Content
13 Content
Sheet1
Cell Formulas
RangeFormula
C2:C13C2=IF(A2="","",IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content"))
D2:D13D2=IF(OR(ISNUMBER(SEARCH("collection",A2,1)),ISNUMBER(SEARCH("product",A2,1))),"Products","Content")
 
Upvote 1

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top