Formula based on the first letter in a cell

povikas

New Member
Joined
Jan 15, 2014
Messages
2
Hello!

I'm a novice when it comes to using Excel, and I didn't find a solution to my problem, so I decided to register and ask for help.

I'm in need of a formula based on the first letter in a cell.

Example - if cell G2 first letter is "A", then cell I2 =C2/D2*F2,
but when cell G2 first letter is "B", then cell I2 =-(C2/D2*E2)

table.JPG

1.1 A little graph for illustration.

So that when i enter letter "A" in cells G2;G3;G4.. it gives me the formula =C2/D2*F2 in cells I2;I3;I4.. or when i enter the letter "B" in cells G2;G3;G4.., it gives me the formula =-(C2/D2*E2) in cells I2;I3;I4..

I hope you did understand my explanation and what it was that i needed :biggrin:

Thanks in advance! :)
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Example - if cell G2 first letter is "A", then cell I2 =C2/D2*F2,
but when cell G2 first letter is "B", then cell I2 =-(C2/D2*E2)

any other letter likely to be entered
two ways to that

Asumming only A or B can be put in the cell and no more than 1 character

then in I2 put

=IF(G2="A", C2/D2*F2, -(C2/D2*E2))

OR

if you could have other letters or blanks
then in I2

=IF(G2="A", C2/D2*F2, IF(G2="B", -(C2/D2*E2), ""))


Now
if any other character in G2 it will just blank the cell

copy the formula down the column

if you have more than 1 character in G and just want to use the 1st character
then
=IF(left(G2,1)="A", C2/D2*F2, IF(left(G2,1)="B", -(C2/D2*E2), ""))
 
Upvote 0
You could also try:
=LOOKUP(G2,{"A",1;"B",-1})*C2/D2*F2

or to make other values in G2 return 0:
=LOOKUP(G2,{"A",1;"B",-1;"C",0;-1E+99,0})*C2/D2*F2
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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