Adding LEN as the 3rd condition in an IF statement

Nameless_

New Member
Joined
Jun 2, 2024
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I'm trying to add LEN in as a 3rd condition to a formula

This is what I think should work but excel doesn't like it

IF((and(b20=0,B22=16,len(b22)=1),"z0"&b22+1,"Z"&b22+1))

I want the output for the cell i'm putting the formula in to show Z0 and then cell B22+1, if the length of B22 is greater than or equal to 2 AND B20 contains 0

B22 will be 1, 2 or 3 digits long
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
There seems to be some confusion regarding the conditions - could you please answer the following: a) IF B22 = 16, then LEN of B22 can never be equal to 1, so the AND will always be FALSE b) "B22 is greater than or equal to 2" - does that mean its LEN or a number? c) "B20 contains 0" - at the moment your condition is set that B20 = 0 - should it be "equal to 0" or "contains 0"?
 
Upvote 0
Thanks for the quick response.
Looks like I had a few typos in the formula

I got it working by using this formula:
=IF(AND(B20=0,B22<16,LEN(B22)=1),"Z0"&(B22+1),"Z"&(B22+1))
 
Upvote 0
Why don't you just check for B22 being less than 10 then you don't need LEN?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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