469,326 Members | 1,359 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

How to remove "(text)" from a string

I have a string value that is equal to:
My neighbor has a dog (Fido).

How can I strip off the "(Fido)" part using VBA?

Nov 13 '05 #1
4 43896
why would you want to do that with VBA? In VBA, you would have to do
this a record at a time, while using SQL you could do the *entire*
table at once.

use InStr() to get the position of the first open parenthesis, then
subtract one, then take everything to the left of it (Left$) and
finally Trim$ it.

Nov 13 '05 #2
I should elaborate....

Each string value will end in "(sometexthere)". Example
My first string (One)
My second string (Two)
My last string (Last)

What's the simplest code that will return everything to the left of the
first "("? I think it uses Left and Len. I just haven't figure it out
yet....

Nov 13 '05 #3
Just figured it out:
left([subject],instr([Subject],"(")-1)

Nov 13 '05 #4
Soundneedle wrote:
I have a string value that is equal to:
My neighbor has a dog (Fido).

How can I strip off the "(Fido)" part using VBA?


Replace(text,"(fido)","")

--
[Oo=w=oO]

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by charlie_M | last post: by
13 posts views Thread by j_ruez | last post: by
2 posts views Thread by Joebloggs | last post: by
4 posts views Thread by Ahmed, Shakir | last post: by
reply views Thread by Adam Pletcher | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.