View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul Robinson Paul Robinson is offline
external usenet poster
 
Posts: 208
Default search and replace loop problem

Hi
How can i be 52 when the loop goes from 65 to 90??
regards
Paul


On Jan 29, 3:19*pm, Ken wrote:
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