If then using wildcard

ec1957

New Member
Joined
Jul 29, 2008
Messages
31
Have a cell that says something like "123 main street".
I want the cell next to it to = Main if it detects main in the other cell and if not then it should say no. I tried this.

=if(B2="*main","Main","No"

However, it is not working. Any thoughts.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Like this?

Excel Workbook
AB
1
2123 main stMain
3123 back stNo
4123 Quartermaine stNo
Check Text
 
Upvote 0
Wow, that was quick. Thank you very much. I am going to see if I can get it to work with multiple requests so if it has main then X and if it has road then x. Thanks again.
 
Upvote 0
Wow, that was quick. Thank you very much. I am going to see if I can get it to work with multiple requests so if it has main then X and if it has road then x. Thanks again.
OK, but if you need further help with this, you would need to spell that out in more exact detail. Also a little more sample data and expected results would help clarify. :)
 
Upvote 0
Hi,
Using Search() with IsNumber() will work I think:
=IF(ISNUMBER(Search("main",B2)),"main","no")

Search returns the number of the starting position of the searched text - so if a number is returned, we know it was found. Funny, I thought the wildcard would work too - scratched my head for a while on that.

Alex

Edit: Lol - while scratching my head Peter had posted the answer almost immediately!
 
Upvote 0
Funny, I thought the wildcard would work too - scratched my head for a while on that.
You could use wildcards ...

=IF(COUNTIF(A2,"* main *"),"main","no")

...but my (limited) understanding is that COUNTIF uses quite a lot of resources, so I would generally go with the ISNUMBER(SEARCH(... method.
 
Upvote 0
Hmmmm. What about if your are trying to do this.

Column A has cells that have addresses.
123 Main Street
234 Presidente Road
987 Forest Drive

Now, in Column B you want it to equal Main if it appears in Column A, Road if Road appears in Column A, Drive if Drive appears in column A.

Basicly, looking for multiple instances of a value instead of just how you helped me look at one?
 
Upvote 0
Hmmmm. What about if your are trying to do this.

Column A has cells that have addresses.
123 Main Street
234 Presidente Road
987 Forest Drive

Now, in Column B you want it to equal Main if it appears in Column A, Road if Road appears in Column A, Drive if Drive appears in column A.

Basicly, looking for multiple instances of a value instead of just how you helped me look at one?
My understanding then is that for those three example, in column B you would expect
Main
Road
Drive

1. Can you confirm the above?

2. What results would you expect in column B for these entries in column A?
234 Smith Street
234 Smith Rd
123 Main Road
 
Upvote 0
Maybe I'm missing something here, but there IS a function named Proper() which will convert the case to a capital first, then lower letters, like main=Main, street=Street, etc. It's worked for me many times!
 
Upvote 0
Sorry, I think I'm making it more confusing.

I want to be able to have a cell in column B look into a cell in column A. I want it to attempt to find any one of three different variables. Depending on the variable I have it looking for, the cell in column B would then = X.
 
Upvote 0

Forum statistics

Threads
1,217,848
Messages
6,138,974
Members
450,170
Latest member
auxplaines

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