How do I ask a cell to look only at the first character in a cell

S

soconfused

I am trying to look at a cell and put a #1 in it:

Example Column C = A-LA41-09-92256 I need a formula here
to put a # 1 if the value is A- or H-

Thanks in advance.

DMM
 
P

Peo Sjoblom

You can't use the same cell, you would need a help cell

=IF(OR(LEFT(C2)="A",LEFT(C2)="H"),1,"")
 
S

soconfused

I didn't pose the question right. I should have said I have a column with
these variables and at the bottom, I want to sum all the A's, H's and V's.
 
P

Peo Sjoblom

Use a help column with a formula and extract the first character

=LEFT(C1)

copy down

assume you put that in D2:D50

then use

=SUM(COUNTIF(C2:C50,{"A","H","V"}))


otherwise try


=SUMPRODUCT(--(LEFT(C2:C50)={"A","H","V"}))
 
S

soconfused

I posed the question wrong. What I really want is a sum of a column with the
first letter of every cell being the variable.

Thanks
 
S

soconfused

Can I get them separated? Like the A's in one row, the H's in another row
and so on?
 
P

Peo Sjoblom

If you copy down the formula it will parse the first character
I am assuming you want to count A, H and V only if they are the first
character

A-LA41-09-92256

would be 1, correct?
 
T

Toppers

=SUMPRODUCT(--(LEFT(C2:C50)="A"))

=SUMPRODUCT(--(LEFT(C2:C50)="H"))

=SUMPRODUCT(--(LEFT(C2:C50)="V"))
 
R

Ron Rosenfeld

I didn't pose the question right. I should have said I have a column with
these variables and at the bottom, I want to sum all the A's, H's and V's.

E1: A
E2: H
E3: V

F1: =COUNTIF(C:C,E1&"*")

Select F1:F3 and Fill Down (<ctrl-D>)


--ron
 
S

soconfused

One more thing, I have this formula =IF(LEFT(H6:H7)="A",SUM(AW6:AW7),"") and
I am getting a value error. HELP please.

Thanks
 
T

Toppers

Enter with Ctrl+Shift+Enter

soconfused said:
One more thing, I have this formula =IF(LEFT(H6:H7)="A",SUM(AW6:AW7),"") and
I am getting a value error. HELP please.

Thanks
 
H

Harlan Grove

Peo Sjoblom said:
otherwise try

=SUMPRODUCT(--(LEFT(C2:C50)={"A","H","V"}))
....

Or try

=SUM(COUNTIF(C2:C50,{"A","H","V"}&"*"))

or a slightly shorter array formula in which it's easier to change the
letters sought,

=COUNT(FIND(LEFT(A1:A30,1),"AHV"))
 
H

Harlan Grove

Toppers said:
=SUMPRODUCT(--(LEFT(C2:C50)="A"))

=SUMPRODUCT(--(LEFT(C2:C50)="H"))

=SUMPRODUCT(--(LEFT(C2:C50)="V"))
....

Urgh!

=COUNTIF(C2:C50,"A*")

=COUNTIF(C2:C50,"H*")

=COUNTIF(C2:C50,"V*")
 
S

Sandy Mann

Harlan Grove said:
=COUNT(FIND(LEFT(A1:A30,1),"AHV"))

That counts in empty cell in my XL97 because the FIND() returns 1 for empty
cells. Is this a bug that was fixed in later versions?
--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

[email protected]
Replace @mailinator.com with @tiscali.co.uk
 
H

Harlan Grove

Sandy Mann said:
That counts in empty cell in my XL97 because the FIND() returns 1
for empty cells. Is this a bug that was fixed in later versions?
....

Not fully bullet-proofed, eh? OK,

=COUNT(FIND(LEFT(A1:A30&"#",1),"AHV"))

You could provide these fixes yourself, you know?
 
S

Sandy Mann

You could provide these fixes yourself, you know?

Actually I was too fixated on there being a bug in FIND() - there are none
so blind as those that think that they already know!

(That's not to say that I would have come up with it anyway.)

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

[email protected]
Replace @mailinator.com with @tiscali.co.uk
 
Top