Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Delete Macro After Running

Is there any way to delete a macro after it has run successfully?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Delete Macro After Running

Bill, here is one way from a previous post
If you only want to use the macro one time then
Place your macro in a module called Module1 together with the macro
deletemodule and run the sub deletemodule.
The whole Module will be deleted, remember that.

Sub deletemodule()
Yourmacro
With ThisWorkbook.VBProject.VBComponents
..Remove .Item("Module1")
End With
End Sub

Sub Yourmacro()
MsgBox "Hi"
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"Bill Oertell" wrote in message
...
Is there any way to delete a macro after it has run successfully?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete Macro After Running

Look at Chip Pearson's page on the VBE

http://www.cpearson.com/excel/vbe.htm

also

http://support.microsoft.com/default...09&Product=xlw
VBA: How To Delete a Sub Procedure After It Runs Once

--
Regards,
Tom Ogilvy


Bill Oertell wrote in message
...
Is there any way to delete a macro after it has run successfully?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Delete Macro After Running

I'm having problems with my Outlook Express, so I'm forced to keep my posts
much shorter than I'd like. But I didn't mention that the Sub I want to
delete has to run as Private in ThisWorkbook.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete Macro After Running

That's why you will need to use Chips page to write code to go in and delete
you procedure.

Eventually you will need to save the workbook to "seal" your deletion, but
you can't do it in the same sub. The code isn't deleted until it completes.

--
Regards,
Tom Ogilvy


Bill Oertell wrote in message
...
I'm having problems with my Outlook Express, so I'm forced to keep my

posts
much shorter than I'd like. But I didn't mention that the Sub I want to
delete has to run as Private in ThisWorkbook.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Delete Macro After Running

I've decided I don't really want to delete the macro after it runs; what if
the user wants to add another entry after they've already saved the
workbook? The macro is supposed to double check their input, and if it
self-deletes that won't be possible. This leads me to another question I'll
post in another topic in a few minutes.

"Tom Ogilvy" wrote in message
...
That's why you will need to use Chips page to write code to go in and

delete
you procedure.

Eventually you will need to save the workbook to "seal" your deletion, but
you can't do it in the same sub. The code isn't deleted until it

completes.

--
Regards,
Tom Ogilvy


Bill Oertell wrote in message
...
I'm having problems with my Outlook Express, so I'm forced to keep my

posts
much shorter than I'd like. But I didn't mention that the Sub I want to
delete has to run as Private in ThisWorkbook.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable running of SelectionChange macro when in another macro? Tonso Excel Discussion (Misc queries) 6 March 21st 10 06:50 PM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 06:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"