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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and Replace in Excel

Status
Not open for further replies.

duffs

Programmer
Sep 22, 2000
48
US
Hi,

Two questions.
1. When using the replace method, what does LookAt do/mean? The only documentation I can find tells me to use either xlPart or xlWhole but doesn't say what these things mean.

2. I'm trying to search for "(" and replace it with " (" for all the cells in my active worksheet. Here's my code:
Sub cleanuptext()
Cells.Select
Selection.Replace What:="T.Rowe", Replacement:="T. Rowe", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Select
Selection.Replace What:="(", Replacement:=" (", LookAt:=xlPart, MatchCase:=False

When my LookAt is xlWhole, I don't get errors, but it doesn't do the replacement. When my LookAt is xlPart, I get this error:
"The formula you typed contains an error..."

Any ideas?

TIA, Susie
End Sub
 
Ahh...wait a sec.

All of my macros are in a separate workbook that I also have open. If I have my workbook with the data open and I run a macro in another open workbook, would the search/replace be trying to execute in the workbook with the macro? If so, how do I tell it to do it in my active workbook instead? (Sorry if this is an obvious question--newbie here.)

Thanks.
 
You will probably do better in the VBA forum, forum707

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Ah, good point. I 'll post this there.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top