# Formula based on the first letter in a cell

#### povikas

##### New Member
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)

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

### Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

#### etaf

##### Well-known Member
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), ""))

#### Teeroy

##### Well-known Member
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

#### povikas

##### New Member
I dub you the Knight of Surrey, godspeed.

Thanks!

Replies
17
Views
756
Replies
1
Views
183
Replies
15
Views
522
Replies
24
Views
508
Replies
3
Views
169

1,195,679
Messages
6,011,119
Members
441,585
Latest member
MargaretBartley

### 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.

### Which adblocker are you using?

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

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