Creating a formula for auto text

ChristineC

New Member
Joined
Apr 19, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am trying to set up auto text based off a value in a cell where there could be multiple values...

For Example in column D the cell will either have a "T", "G", or "N"... and I am trying to have auto text (for T=94010 and for G=36941) populate into another column. (Don't care about any other values at this point)

I've managed to do a If formula for the T value but cannot figure out how add on the G value this way. Some googling has come up with VLOOKUP ideas but I'm so lost with that as well. I really aughtta take a refresher course...
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
A few different options to see how to achieve multiple results:

Book1
DEFGH
1IFS()LOOKUP()Nested IF()SWITCH()
2T94010940109401094010
3G36941369413694136941
4N77001770017700177001
5V#N/A94010  
Sheet1
Cell Formulas
RangeFormula
E2:E5E2=IFS(D2="T",94010,D2="G",36941,D2="N",77001)
F2:F5F2=LOOKUP(D2,{"G","N","T"},{36941,77001,94010})
G2:G5G2=IF(D2="T",94010,IF(D2="G",36941,IF(D2="N",77001,"")))
H2:H5H2=SWITCH(D2,"T",94010,"G",36941,"N",77001,"")


Notice with IFS() you get #N/A if the value is anything other than your accepted values. You could add a condition for blank, but anything else and you would need to wrap it IFERROR or IFNA or something like that.

With LOOKUP(), if the value does not match one of the accepted values, it chooses the next closest value alphabetically. Again, you could put in a condition for blank, but that is about it.

The nested IF() and SWITCH() formulas give you a little bit more control to handle values either blank or a different letter.
 
Upvote 0
Solution
A few different options to see how to achieve multiple results:

Book1
DEFGH
1IFS()LOOKUP()Nested IF()SWITCH()
2T94010940109401094010
3G36941369413694136941
4N77001770017700177001
5V#N/A94010  
Sheet1
Cell Formulas
RangeFormula
E2:E5E2=IFS(D2="T",94010,D2="G",36941,D2="N",77001)
F2:F5F2=LOOKUP(D2,{"G","N","T"},{36941,77001,94010})
G2:G5G2=IF(D2="T",94010,IF(D2="G",36941,IF(D2="N",77001,"")))
H2:H5H2=SWITCH(D2,"T",94010,"G",36941,"N",77001,"")


Notice with IFS() you get #N/A if the value is anything other than your accepted values. You could add a condition for blank, but anything else and you would need to wrap it IFERROR or IFNA or something like that.

With LOOKUP(), if the value does not match one of the accepted values, it chooses the next closest value alphabetically. Again, you could put in a condition for blank, but that is about it.

The nested IF() and SWITCH() formulas give you a little bit more control to handle values either blank or a different letter.

This did the trick, thank you!
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

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