Finding "End" and nothing but "End"

E

Ed

I wrote a program with the command "End" signalling VBA to halt processing.
I find that I now need to convert all of those "End" to "Exit Sub" and "Exit
Function" in order for the program to be compatible with more operating
systems.

I need to search for "End" but a regular search also lands me on "End With"
and "End Sub" and a variety of other "End . . ." Is there anyway to search
withing VBA coding for "End^P" (like can be done in Word) and have it land
on only the command "End"?

Thanks,
Ed
 
J

John F

I could only suggest that you export the form / module. Modify it in your
favorite editor and then import it again.

John.
 
A

asrisl

Ed,

You cannot do what you want directly, but here is a trick that I learned.

Do a global find and replace:
"End Sub" with "Xnd_Sub"
"End Function " with "Xnd_Function"
"End If" with "Xnd_If"
"End With" with "Xnd_With"

All that should be left of the "Ends" are pure "End" statements

F&R "End" with "End 'and nothing but end" (or other silly statement, or
your initials, etc.to make the End and following text unique)
(For this final F&R, choose the whole word, case sensitive options, so
as to not affect 'send', 'bend' and very importantly, 'wend'. You may
actually want to this F&R manually, because you may have "End" in a comment
or in msgbox text. You choose.
Make sure the apostrophe is in place to comment out the 'and nothing but
end' text).

Then, reverse the Xnd_Sub, etc. to End Sub etc.

That should do what you want.

Roy

Ed said:
I wrote a program with the command "End" signalling VBA to halt processing.
I find that I now need to convert all of those "End" to "Exit Sub" and
"Exit Function" in order for the program to be compatible with more
operatingsystems.

I need to search for "End" but a regular search also lands me on "End
With" and "End Sub" and a variety of other "End . . ." Is there anyway to
search withing VBA coding for "End^P" (like can be done in Word) and have
it land on only the command "End"?
=====================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top