OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Finding a specific text string within a cell

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
au79
Newbie
Newbie


Joined: 04 Sep 2008
Posts: 2

PostPosted: Thu Sep 04, 2008 5:49 pm    Post subject: Finding a specific text string within a cell Reply with quote

Hi all,

I've searched long in this forum for a solution, but to no avail. My goal is to identify a particular text string and display it on the adjacent cell.

Column A has these items:

LC51M [Magenta]
LC51Y [Yellow]
LC51BK [Black]
LC51C [Cyan]

In column B I tried different variations of this formula:

=IF(find("Magenta";A1)=".*\[Magenta\].*";"Magenta";"")

But nothing works. I realized that FIND() returns a numeric value and not a text string. How can I isolate the color names and display them in their own column?

Any help will be greatly appreciated.
Back to top
View user's profile Send private message
uros
Super User
Super User


Joined: 22 May 2003
Posts: 601
Location: Slovenia

PostPosted: Thu Sep 04, 2008 11:01 pm    Post subject: Reply with quote

Hi au79!
au79 wrote:
How can I isolate the color names and display them in their own column?

Put this formula in B1 and copy down...
    =MID(A1;FIND("[";A1)+1;FIND("]";A1)-FIND("[";A1)-1)
Uros
Back to top
View user's profile Send private message
keme
Moderator
Moderator


Joined: 30 Aug 2004
Posts: 2910
Location: Egersund, Norway

PostPosted: Fri Sep 05, 2008 4:25 am    Post subject: Re: Finding a specific text string within a cell Reply with quote

Another important thing to note:
au79 wrote:
[ ... ]
=IF(find("Magenta";A1)=".*\[Magenta\].*";"Magenta";"")

If you need more advanced text searching, you can use regular expressions, as you try to do with the compare here.
FIND() doesn't support the use of regular expressions, and as far as I can see, compare operations don't either.
On the other hand, SEARCH() does support the use of regex.
Back to top
View user's profile Send private message
au79
Newbie
Newbie


Joined: 04 Sep 2008
Posts: 2

PostPosted: Fri Sep 05, 2008 7:14 am    Post subject: Thanks! Reply with quote

Thank you uros and keme for your prompt response.

Uros solution worked perfectly (although I don't understand how its doing it).

Thanks a million.
Back to top
View user's profile Send private message
RickRandom
Super User
Super User


Joined: 27 Jan 2006
Posts: 1082
Location: UK

PostPosted: Fri Sep 05, 2008 7:25 am    Post subject: Re: Thanks! Reply with quote

au79 wrote:
Uros solution worked perfectly (although I don't understand how its doing it)
My understanding is that it FINDs the positions of the 2 square brackets and then gets the text in the MIDdle of them.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group