How to delete particular contexts from cell?

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
220
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:

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

iggydarsa

Well-known Member
Joined
Jun 28, 2005
Messages
1,647
<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>
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,994
Consider using =TRIM(LEFT(A1,FIND("-",A1&"-")-1)) to allow for cells which don't have hyphens.
 

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
220
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 :)
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,994

ADVERTISEMENT

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.
 

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
220
Thanks Oaktree!

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

What does this due?

I appreciate your explanation.

~ Busypee :)
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,994
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.
 

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
220
Awesome. I completely understand the forumla used now. Thanks so much for the explanation Oaktree! :)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,383
Messages
5,601,316
Members
414,441
Latest member
KellyTheKid

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
Top