Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace command

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
Here is a vba code fragement:

Dim myString as String
myString="sdf abc eee abd xqq"
replace(myString,"abc","ab")
replace(myString,"abd","ab")

Can I consolidate the last two commands? I need to know how to use wildcards in vba. I tried "ab?" and that did not work.
 
Do we know that there are always going to be 3 characters?

I would look at the INSTR function.

myString="sdf abc eee abd xqq"

? instr(mystring,"ab")
5

mystring=mid(mystring,1,instr(mystring,"ab")+1)+mid(mystring,instr(mystring,"ab")+3)

? myString
sdf ab eee abd xqq

of course you would have to set up a loop and check for a second occurance of 'abX'

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top