How to delete particular contexts from cell?

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
226
This might be a very basic question, but how do you delete specific contents from a cell?

I.E. Here are how my contents in column A look:

Security 1 - Blah Blah - Blah Blah
Security 2 - La La - La La

How would I delete the stuff after the first "-"? Essentially, I just want to keep the Security 1 from cell A1.

Would it begin with this function? =IF(ISNUMBER(FIND("-",A1)

Thanks for the help!

~ Busypee ;)
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
<html><head><title>Excel Jeanie HTML</title></head><body>

<!-- ######### Start Created Html Code To Copy ########## -->

Excel Workbook
AB
1Security 1 - Blah Blah - Blah BlahSecurity 1
2Security 2 - La La - La LaSecurity 2
Sheet1




<!-- ######### End Created Html Code To Copy ########## -->

</body></html>
 
Upvote 0
Consider using =TRIM(LEFT(A1,FIND("-",A1&"-")-1)) to allow for cells which don't have hyphens.
 
Upvote 0
Thanks guys!

Could you please explain what the &"-" after the A1 in your code does Oaktree?

Also, what does the -1 mean that follows the closed bracket?

I have seen similar forumals written before and have always wondering what those things meant! Thanks for your help once again.

~ Busypee :)
 
Upvote 0
The &"-" appends a hyphen to the end of the string in A1 so that the FIND function will always find a hyphen. That's in place for cases where A1 does not already have a hyphen, as =FIND("-","test") would return a #VALUE! error.
 
Upvote 0
Thanks Oaktree!

What about the "-1" in your code: A1&"-")-1)

What does this due?

I appreciate your explanation.

~ Busypee :)
 
Upvote 0
If your sting was "TEST-1", FIND("-",A1) would return 5, as the hyphen is in the 5th position... but, you'd want the left *4* characters, so you subtract 1 from the result of FIND.
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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