View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default search and replace loop problem

I am using the following code to replace all letters from a worksheet

Sub deletetest()

Dim ws As Worksheet
Dim Rep As String

Set ws = ActiveSheet

For i = 65 To 90

Rep = Chr(i)

Debug.Print Rep

ws.Cells.Replace What:=Rep, Replacement:="", LookAt:=xlPart,
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
Next

End Sub

For some reason it won't replace the H's. My immediate window shows
that Rep was H when i was 52. If I change the code to manually make
Rep="H" it replaces the H's. If I run search and replace on the
worksheet for H it replaces the H's; it is just the H in the loop that
it seems to skip.

Can someone tell me what is happening?

Thanks

Ken