Determine if last character meets condition

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
414
Office Version
  1. 365
Platform
  1. Windows
Hello All

May I ask the board for help with a formula to find the last number in a cell and if that number meets a condition put a letter in the adjacent cell.

In cell A1 I have numbers as such 254671 (these numbers vary in length but not normally more than 8 in length). I want to know if the last numeral on the right is a 1 and if so then enter in the adjacent cell (B1) the letter y if not then leave blank.

Thanks in advance.

Regards
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hello JB Scotland

Many thanks for replying. When I enter your formula it returns the #value, will that be due to some unforeseen formatting?

Regards
 
Upvote 0
You will get #VALUE if A1 is blank or contains text with no number at the right end. If you want to avoid the #VALUE error use this:

=IF(RIGHT(A1,1)="1","y","")
 
Upvote 0
Hello JB Scotland

That works an absolute treat and many thanks for your help it is much appreciated.

Regards
 
Upvote 0
Here are two more ways in which to do it...

=LEFT("Y",RIGHT(A1)="1")

=MID("Y",1,RIGHT(A1)="1")
 
Upvote 0
Rick - neat.

In the same vein if you like your RIGHTS:

=RIGHT("Y",RIGHT(A1)="1")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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