Conditional Left( extract formula)

srizki

Well-known Member
Joined
Jan 14, 2003
Messages
1,860
Office Version
  1. 365
Platform
  1. Windows
Column A has reference ID, that consists of 5 to 15 numbers or alphabets of mix. Most of them are account numbers with extension of invoice number. I am trying to extract account number for future references.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Some account numbers I know that they consist of 8 digits. One of them starts with Y, so if there is Y219417720111210, I want my formula to extract first 8 characters; so far easy, but not all the numbers is column have Y, so I want a formula that should read column A and if the number starts with Y, it should bring first 8 characters otherwise bring everything in it.<o:p></o:p>
To clarify further, I am using formula something like this.<o:p></o:p>
=IF(A1=”Y*”,LEFT(A1,8),A1), This formula is transferring everything in the cell, ignoring Y.<o:p></o:p>
<o:p> </o:p>
Thanks<o:p></o:p>
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Does the following do what you want?

Code:
=IF(LEFT(A1,1)="Y",LEFT(A1,8),A1)


Matty
 
Upvote 0
The "1" on the first LEFT part of the formula I posted is, in actual fact, superfluous. As Hotpepper has shown, if it's the first character you want (which it is), the num_chars element is not required.

Matty
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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