Macros stopping on errors


Posted by Ken on January 28, 2002 10:42 AM

Hi,

I have a number of macros that have worked for years without problems, now they are hanging on undeclared variables "apparently", I did have the "undeclared variables" checkbox checked for a while, but now it is not, it is still hanging on undeclared variables. Any help would be appreciated. Following is an example macro that has worked in the past but is hanging now.

Sub convert()
Application.ScreenUpdating = False
For Each Worksheet In ActiveWorkbook.Worksheets
Worksheet.Select
Range("A9:A100").Select
Selection.Replace What:="+", Replacement:="X", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Range("B9:B100").Select
Selection.Replace What:=".", Replacement:="""", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="+", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
ActiveWindow.LargeScroll Down:=-10
Range("A10").Select
Next Worksheet
Sheets(1).Select
Application.ScreenUpdating = True
ActiveWorkbook.Save
End Sub

Thanks
Ken

Posted by Juan Pablo G. on January 28, 2002 11:43 AM

I put

Dim Worksheet as Worksheet

at the top and it worked, but I wouldn't use Worksheet as a variable name. I'd rather go with Sh, WS, WST, or something else

Juan Pablo G.



Posted by Ken on January 28, 2002 1:25 PM

Thanks Juan Pablo