# Some expert Excel/Open Office help?

**URL:** <https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374>\
**Category:** Factual Questions\
**Created:** [April 30, 2012, 12:25am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374 "2012-04-30T00:25:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boyo\_Jim](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Boyo\_Jim](https://boards.straightdope.com/u/Boyo_Jim)\
**Post date:** [April 30, 2012, 12:25am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/1 "2012-04-30T00:25:23Z")

</div>

I have a column of text strings. Some but not all of the cells have comments contained within parentheses to the right of the string, but within the same cell.

I need a formula that will copy the the string up to but not including the first open parenthesis “(”, and also not including a blank space if it immediately precedes the parenthesis (which one does in most cases).

The formula can either be written to equal that string, or to place the string in some other adjacent column.

I mentioned Open Office because I’m using it at home, but if you give me an Excel example it will probably be close enough to work with a little fiddling. There’s nearly 10.000 rows, so doing this manually would take an enormous amount of time.

---

<div class="post-metadata">

**Author:** ![Dave\_Hartwick](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Dave\_Hartwick](https://boards.straightdope.com/u/Dave_Hartwick)\
**Post date:** [April 30, 2012, 12:58am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/2 "2012-04-30T00:58:27Z")

</div>

Assuming your string is in d22 and less than 5000 characters (and that I understood the question) (and that I didn’t get ninja’d while fooling with it):

=LEFT(D22,MIN(IFERROR(FIND(" (",D22)-1,5000),IFERROR(FIND("(",D22)-1,5000),LEN(D22)))

---

<div class="post-metadata">

**Author:** ![Boyo\_Jim](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Boyo\_Jim](https://boards.straightdope.com/u/Boyo_Jim)\
**Post date:** [April 30, 2012, 1:17am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/3 "2012-04-30T01:17:49Z")

</div>

Well, it didn’t work by just pasting it in and changing the cell reference, but that would be too good to be true anyway. I gonna assume there’s some syntax differences to make it work on OE. This is an excellent start, and I thank you.

---

<div class="post-metadata">

**Author:** ![Blunt](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Blunt](https://boards.straightdope.com/u/Blunt)\
**Post date:** [April 30, 2012, 1:26am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/4 "2012-04-30T01:26:34Z")

</div>

Not sure if Open Office has the text to columns feature, but if it does could you use that? Use the ( as the delimter and you should end up with everything to the left of it in its own column. You could then use trim to get rid of the trailing space if necessary I think.

---

<div class="post-metadata">

**Author:** ![Typo\_Knig](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@Typo\_Knig](https://boards.straightdope.com/u/Typo_Knig)\
**Post date:** [April 30, 2012, 1:31am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/5 "2012-04-30T01:31:53Z")

</div>

Keep in mind that OpenOffice uses semicolon (😉 to separate arguments in a function call, whereas Excel uses a comma (,).

---

<div class="post-metadata">

**Author:** ![Typo\_Knig](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@Typo\_Knig](https://boards.straightdope.com/u/Typo_Knig)\
**Post date:** [April 30, 2012, 1:33am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/6 "2012-04-30T01:33:17Z")

</div>

Arg! Semicolon in parens - not smiley! D’Oh!

---

<div class="post-metadata">

**Author:** ![Boyo\_Jim](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Boyo\_Jim](https://boards.straightdope.com/u/Boyo_Jim)\
**Post date:** [April 30, 2012, 1:34am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/7 "2012-04-30T01:34:38Z")

</div>

> [@Dave\_Hartwick](#):
>
> Assuming your string is in d22 and less than 5000 characters (and that I understood the question) (and that I didn’t get ninja’d while fooling with it):
> 
> =LEFT(D22,MIN(IFERROR(FIND(" (“,D22)-1,5000),IFERROR(FIND(”(",D22)-1,5000),LEN(D22)))

This has some paren issues, I think. There aren’t complete pairs (there are two more open parens than close parens). Before I look at figuring out where they would logically go, I’m gonna look at Blunt’s idea of seeing if I can get it to load into the spreadsheet from the source file in way that solves the problem.

---

<div class="post-metadata">

**Author:** ![Boyo\_Jim](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Boyo\_Jim](https://boards.straightdope.com/u/Boyo_Jim)\
**Post date:** [April 30, 2012, 1:47am UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/8 "2012-04-30T01:47:15Z")

</div>

Ok, I’ve solved the problem taking a little but of this and a little bit of that.

I imported the column into a spreadsheet, where I searched for “\<space\>(”, and replaced these with just a paren then I just copied the column out into Notepad.

Then I copied it back into an empty spreadsheet using the paren as a column delimiter, and Whoo hoo it works. Thanks!

---

<div class="post-metadata">

**Author:** ![phaemon](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@phaemon](https://boards.straightdope.com/u/phaemon)\
**Post date:** [May 1, 2012, 1:28pm UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/9 "2012-05-01T13:28:49Z")

</div>

Well, it’s done, but here’s how you could have done it just in open/libreoffice:

Select the column you want  
Edit…Replace " (" with “(” (get rid of leading spaces)  
Tools…Text to Column  
Use “(” as a delimiter  
You’ll now have a seperate column with the comments and the closing “)”  
Edit…Replace “)” with “” (just to clean it up)

All done!

---

<div class="post-metadata">

**Author:** ![phaemon](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@phaemon](https://boards.straightdope.com/u/phaemon)\
**Post date:** [May 1, 2012, 1:54pm UTC](https://boards.straightdope.com/t/some-expert-excel-open-office-help/620374/10 "2012-05-01T13:54:59Z")

</div>

And, for completeness, if you’d wanted to do this to a text file, say mydata.txt, outside of \*office then:

sed ‘s/\s\*(.\*//’ mydata.txt \> mydatawithoutcomments.txt
