IF and LEFT

Lauren3077

New Member
Joined
Apr 9, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I am trying to write a function for IF the date in column G2 starts with 1, it should put the letter N in the cell. If the date starts with 2, it should be B. I guess it gets tricky when the months get up to 10 and the letter should be T. I have found some formulas that show how to use Left and the month, but they will only produce a numeric value. I need it to be a specific letter.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
One option would be like
Excel Formula:
=CHOOSE(MONTH(G2),"N","B","A","C","X","L")
or you could create a lookup table with the month number & letter & then use xlookup
 
Upvote 0
Solution
Seems to me you could use the CHOOSE function. If I'm reading your question right, you want Jan = N, Feb = B, Oct Nov and Dec = T. What about the other values, like Mar-Sept? Blank? Something else?

Try this. In the cell you want the letter, enter =CHOOSE(month(G2),"N","B","x","x","x","x","x","x","x","T","T","T")

The MONTH function will return a number from 1 to 12. That number will be used by the CHOOSE function to display the nth entry in the list. The first entry for Jan, the second for Feb, the 10th, 11th, and 12th for Oct-Dec. You can replace the 'x' with whatever letters (or blank) you want for Mar-Sep.

Hope this help.

Bill B.
 
Upvote 0
Hi,

Here's just another way if I understand correctly:

Book3.xlsx
ABCD
11/15/2021nN
22/15/2021bB
33/15/2021rR
44/15/2021rR
55/15/2021yY
66/15/2021nN
77/15/2021lL
88/15/2021gG
99/15/2021pP
1010/15/2021tT
1111/15/2021vV
1212/15/2021cC
Sheet917
Cell Formulas
RangeFormula
C1:C12C1=RIGHT(TEXT(A1,"mmm"))
D1:D12D1=UPPER(RIGHT(TEXT(A1,"mmm")))
 
Upvote 0
Thanks so much. That worked on the first try (which never happens to me)!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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