search for capital letter at end of text string

R

Roger on Excel

I need to search for a word with a capital letter at the end of the string.

For example

Hydrochloric acid 1M

Ive tried using =IF(RIGHT(D18)="M","yes","no"), but it doesnt differentiate
between lower case and upper case.

Can anyone help?

Thanks,

Roger
 
R

Rick Rothstein \(MVP - VB\)

Try it this way in order to check for a specific upper cased letter...

=IF(EXACT(RIGHT(D18),"M"),"yes","no")

and this way to see if the letter, no matter which one it is, is upper
case...

=IF(AND(CODE(RIGHT(D18))>=65,CODE(RIGHT(D18))<=91),"yes","no")

Rick
 
D

Dave Peterson

If the last character is always a letter:
=IF(EXACT(UPPER(RIGHT(D18,1)),RIGHT(D18,1)),"Upper","NotUpper")

But this will return Upper for numbers, punctionation, special characters, ...

=IF(AND(CODE(RIGHT(D18,1))>=CODE("A"),CODE(RIGHT(D18,1))<=CODE("Z")),
"upper","not upper")

Checks for A to Z.
 
D

Dave Peterson

Check your other post.
I need to search for a word with a capital letter at the end of the string.

For example

Hydrochloric acid 1M

Ive tried using =IF(RIGHT(D18)="M","yes","no"), but it doesnt differentiate
between lower case and upper case.

Can anyone help?

Thanks,

Roger
 
R

Roger on Excel

Thanks for the help,

Best regards,

Roger

Dave Peterson said:
If the last character is always a letter:
=IF(EXACT(UPPER(RIGHT(D18,1)),RIGHT(D18,1)),"Upper","NotUpper")

But this will return Upper for numbers, punctionation, special characters, ...

=IF(AND(CODE(RIGHT(D18,1))>=CODE("A"),CODE(RIGHT(D18,1))<=CODE("Z")),
"upper","not upper")

Checks for A to Z.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top