View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cooz Cooz is offline
external usenet poster
 
Posts: 24
Default Replace in ranges does not work.

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