Thread
:
Macro Only works Once
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Macro Only works Once
try this idea
Sub replaceletters()
With Selection
For i = 97 To 122
.Replace what:=Chr(i), replacement:="" 'a-z
.Replace what:=Chr(42), replacement:="" '*
.Replace what:=Chr(45), replacement:="" '-
Next i
End With
End Sub
--
Don Guillett
SalesAid Software
wrote in message
ups.com...
Hi all,
I have a problem with macros. I have a macro that used to work as
desired, and now it only works the first time Excel is opened, then it
doesn't run at all:
Sub RemoveLetters()
Selection.Replace What:="a", Replacement:="", MatchCase:=False
Selection.Replace What:="b", Replacement:="", MatchCase:=False
Selection.Replace What:="c", Replacement:="", MatchCase:=False
Selection.Replace What:="d", Replacement:="", MatchCase:=False
Selection.Replace What:="e", Replacement:="", MatchCase:=False
Selection.Replace What:="f", Replacement:="", MatchCase:=False
Selection.Replace What:="g", Replacement:="", MatchCase:=False
Selection.Replace What:="h", Replacement:="", MatchCase:=False
Selection.Replace What:="i", Replacement:="", MatchCase:=False
Selection.Replace What:="j", Replacement:="", MatchCase:=False
Selection.Replace What:="k", Replacement:="", MatchCase:=False
Selection.Replace What:="l", Replacement:="", MatchCase:=False
Selection.Replace What:="m", Replacement:="", MatchCase:=False
Selection.Replace What:="n", Replacement:="", MatchCase:=False
Selection.Replace What:="o", Replacement:="", MatchCase:=False
Selection.Replace What:="p", Replacement:="", MatchCase:=False
Selection.Replace What:="q", Replacement:="", MatchCase:=False
Selection.Replace What:="r", Replacement:="", MatchCase:=False
Selection.Replace What:="s", Replacement:="", MatchCase:=False
Selection.Replace What:="t", Replacement:="", MatchCase:=False
Selection.Replace What:="u", Replacement:="", MatchCase:=False
Selection.Replace What:="v", Replacement:="", MatchCase:=False
Selection.Replace What:="w", Replacement:="", MatchCase:=False
Selection.Replace What:="x", Replacement:="", MatchCase:=False
Selection.Replace What:="y", Replacement:="", MatchCase:=False
Selection.Replace What:="z", Replacement:="", MatchCase:=False
Selection.Replace What:="~*", Replacement:="", MatchCase:=False
Selection.Replace What:="--*", Replacement:="", MatchCase:=False
Selection.Replace What:="-", Replacement:="0", LookAt:=xlWhole,
MatchCase:=False
End Sub
If I close Excel, and then open it again, the macro works once, then
doesn't work again, until I close and reopen Excel.
Any idea why this is?
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett