Need quick help for IIF function. Returning results of a certain format

Aero11

New Member
Joined
Sep 16, 2011
Messages
34
Hello everyone. I have been trying to figure out queries for a little while now at work, and usually I can find my answer by myself. However, I have been unable to find my answer this time, and I'm hoping to get some help here.

What I am trying to do is to create an IIF function that returns results in a certain format. I'm sure this can be done, but I don't think I am using the right commands. Specifically, I want the query to return the result "Commercial" if the search result is in the format 12-34-56, and return "Military" if the number is in any other format.

Something like...

IIF((Wo_headc.ATA_MAN_NBR) LIKE "**-**-**",'Commercial','Military')

??

Please help. Thanks! This is driving me crazy!
 
Didn't get the answer I was looking for here, but I ended up figuring out how to do what I wanted.

Instead of using "%"'s, the trick is to use underscores "_"'s. So the proper syntax is

IIF((Wo_headc.ATA_MAN_NBR) Like '__-__-__','Commercial','Military')
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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