By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,400 Members | 981 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,400 IT Pros & Developers. It's quick & easy.

How to remove "(text)" from a string

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
Just figured it out:
left([subject],instr([Subject],"(")-1)

Nov 13 '05 #4

P: n/a
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.