• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Excel if/then

If I have a letter in cell A1, and want a corresponding number to go in A2, what would my formula be?

I would like the number 1 for A OR F; 2 for B OR G; 3 for C OR H; 4 for D OR J

Is it practical to use if/then?  What other formula could I use?
0
Frankkadaf
Asked:
Frankkadaf
  • 3
1 Solution
 
ScriptAddictCommented:
This should work
=IF(OR(A1="A",A1="F"),1,IF(OR(A1="B",A1="G"),2,IF(OR(A1="C",A1="H"),3,IF(OR(A1="D",A1="J"),4,))))

Open in new window

0
 
ScriptAddictCommented:
Another good option would to use a reference table placed somewhere else and Assign values by letter.  Then you could just do a lookup on the reference table.  I think I would use that approach as it's much cleaner if you ever need to add letters.
0
 
ScriptAddictCommented:
Here's what I played with.
IfthenAlternatives.xlsx
0
 
Saqib Husain, SyedEngineerCommented:
If it is always 2 at a time then you can use something like

=INT(MATCH(A1,{"";"A";"F";"B";"G";"C";"H";"D";"J"},0)/2)
0
 
FrankkadafAuthor Commented:
Great formula, easy to use, especially if there are only a few options.  The lookup is also an option.

Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now