Replace in ranges does not work.

  • Thread starter Thread starter Cooz
  • Start date Start date
C

Cooz

Hi everyone,

My copy of Excel 2003 shows some unexpected behavior with regard to
replacing strings within a range. I have this code:

Set shtImp = ActiveWorkbook.Worksheets("Import")
With shtImp.UsedRange
.Replace What:="=", Replacement:="'=", LookAt:=xlPart,
SearchOrder:=xlByColumns
End With

The result of this code is the replacement of "=" by "'=" in the entire
workbook, where only the replacement of the string on the Import worksheet
was intended.
How do I modify the code to achieve the desired result? I do not want to
have to activate the Import worksheet, select the range in question and
perform replacing within the selection.

Can anyone help me out here?
Thank you,

Cooz
 
If you ever come across this strange behavior, try Help | Detect and
Repair... and/or Open -> Open and Repair...
It obviously had to do with some kind of corruption. The code works fine now.

Cooz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top