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

Don

That took care of it, thanks.

It was definitely a problem with formulas, but, I don't understand
exactly how it picked the letters to not replace. Subsequent
troubleshooting on sheet2 caused it to not delete any i's, and running
it again on sheet3 did not have any problems, all the letters were
gone. Apparently it was okay changing CHAR to CHR and then changing
CHR to HR, but when it came ot changing HR to R it quit after changing
the formulas and did not replace any more H's. On sheet2 I had an IF
formula and it changed to =F(... and then stopped replacing i's. My
third sheet had no formulas, hence,no problems.

Do you know of a better way to replace all the letters in a worksheet?

Thanks

Ken



n Jan 29, 2:08*pm, Don Guillett Excel MVP
wrote:
I don't understand what you are doing or why you are doing it THAT way
but if you have formlas you would have a problem. So add

On Error Resume Next

before your for

On Jan 29, 9:19*am, 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- Hide quoted text -


- Show quoted text -