IF Statement with multiple or conditions

aquad6

New Member
Joined
Jun 23, 2023
Messages
10
Office Version
  1. 365
Platform
  1. MacOS
Hi There!
I am trying to write a formula that allows me to place a dash before the last character in a cell text if it is an A,B,C etc. For example, if I have a sku that reads JH004A and I would like a formula that will populate another cell with JH004-A. IF it doesn't contain A,B,C etc. I want the other cell to read False. So far this formula =IF(AND(RIGHT(A2,1)="B"),LEFT(A2,LEN(A2)-1)&"-"&RIGHT(A2,1)) works but only if the end character is a "B", I can't figure out had to make it work if the end character is an A, or C. Any help would be greatly appreciated!! Thank you!
 
Some of my skus have two Alphabetical characters at the end while others have only one.
If they are the only possibilities then you could try this formula.

23 06 24.xlsm
AB
1MO456CDMO456-CD
2AAA1BAAA1-B
3A3AAA3-AA
412ab12-ab
51A2B3C1A2B3-C
Dash
Cell Formulas
RangeFormula
B1:B5B1=REPLACE(A1,LEN(A1)-ISERR(-MID(A1,LEN(A1)-1,1)),0,"-")
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
.. or for any number of alphabet characters (including zero) at the end

23 06 24.xlsm
AB
1MO456CDMO456-CD
2AAA1BAAA1-B
3A3AAAA3-AAA
4AAAC123AAAC123
512abc12-abc
61A2B3CCCC1A2B3-CCCC
Dash (2)
Cell Formulas
RangeFormula
B1:B6B1=LET(p,LEN(TEXTBEFORE(A1,SEQUENCE(10)-1,-1))+1,IF(p=LEN(A1),A1,REPLACE(A1,p+1,0,"-")))
 
Upvote 0
In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

On this occasion I have merged both threads.
 
Upvote 0

Forum statistics

Threads
1,223,774
Messages
6,174,453
Members
452,565
Latest member
curtoliver68

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