IF Help (Second last chracter in cell matches)

Mr. Alex

New Member
Joined
Nov 26, 2003
Messages
34
Howdy,

I have a column of text like this

F26139
J28661
D798
D29766
D16842_A
D16842_B
D16842_C
D16842_D
J29687_A
J29687_B
J29687_C
J29687_D
C353_A
C353_B
A16484
G28194
G20034
A14916
H18803_A
H18803_B
H18803_C
H18803_D


I need to remove the _A _B _C from the cell, only when present. My column is over 2000 rows long and the _A _B _C shows up everywhere... also, it spans the whole alphabet..

I figure some sort of IF statement would do it, but I need to isolate the underscore _ … It will always be the second last character in the cell.

Any ideas?

Thanks

Mr. Alex
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi,

Another way is ...
=IF(MID("**"&A1,LEN("**"&A1)-1,1)="_",LEFT(A1,LEN(A1)-2),A1)

HTH

Alan
 
Upvote 0
Try:

=IF(MID(A1,LEN(A1)-1,1)="_",LEFT(A1,LEN(A1)-2),A1)
 
Upvote 0
Hello,

Using a formula

=IF(ISERROR(FIND("_",A1)),A1,LEFT(A1,FIND("_",A1)-1))

or

have you tried find '_?' and replace with nothing?
 
Upvote 0
Holy cow, thats sweet man!

Thank you everyone for your help, and Fairwinds for the sweetest bit of code i've seen in quite some time!

I think Fairwinds, if you keep this up, you'll raise the bar for us all. :wink:


Mr. Alex
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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