Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Can a sub be deleted via macro?

In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Can a sub be deleted via macro?

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

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"danhattan" wrote in message
...
In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another
sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Can a sub be deleted via macro?

Tried this but it doesn't compile correctly because it doesn't recognize
CodeModule as a variable type. I started to create a variable just to look at
the list of available variable types and don't see CodeModule in there. Is
there another step needed to make this a valid variable type, or should I be
using another variable type altogether?

Also, thanks for the reference to the link. It looks really useful and I've
already bookmarked it. And as always, thanks for the help. You're truly
invaluable to those of us trying to learn our way up the ladder.


"Bob Phillips" wrote:

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

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"danhattan" wrote in message
...
In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another
sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Can a sub be deleted via macro?

Take a look he

http://cpearson.com/excel/vbe.htm#DeleteProcedure

In article ,
danhattan wrote:

In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Can a sub be deleted via macro?

Hi JE.

Tried this but it doesn't compile correctly because it doesn't recognize
CodeModule as a variable type. I started to create a variable just to look at
the list of available variable types and don't see CodeModule in there. Is
there another step needed to make this a valid variable type, or should I be
using another variable type altogether?

Thoughts? Thanks for the reference to the link. It looks really useful.


"JE McGimpsey" wrote:

Take a look he

http://cpearson.com/excel/vbe.htm#DeleteProcedure

In article ,
danhattan wrote:

In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Can a sub be deleted via macro?

Start at the top of that web page and read starting with:
"Before using these procedures, you'll need to set a reference in VBA to the VBA
Extensibility library."

There are other restrictions, too.

danhattan wrote:

Hi JE.

Tried this but it doesn't compile correctly because it doesn't recognize
CodeModule as a variable type. I started to create a variable just to look at
the list of available variable types and don't see CodeModule in there. Is
there another step needed to make this a valid variable type, or should I be
using another variable type altogether?

Thoughts? Thanks for the reference to the link. It looks really useful.

"JE McGimpsey" wrote:

Take a look he

http://cpearson.com/excel/vbe.htm#DeleteProcedure

In article ,
danhattan wrote:

In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.



--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Can a sub be deleted via macro?

Thanks. That cleared up a lot of questions I had. Very much appreciated.

"Dave Peterson" wrote:

Start at the top of that web page and read starting with:
"Before using these procedures, you'll need to set a reference in VBA to the VBA
Extensibility library."

There are other restrictions, too.

danhattan wrote:

Hi JE.

Tried this but it doesn't compile correctly because it doesn't recognize
CodeModule as a variable type. I started to create a variable just to look at
the list of available variable types and don't see CodeModule in there. Is
there another step needed to make this a valid variable type, or should I be
using another variable type altogether?

Thoughts? Thanks for the reference to the link. It looks really useful.

"JE McGimpsey" wrote:

Take a look he

http://cpearson.com/excel/vbe.htm#DeleteProcedure

In article ,
danhattan wrote:

In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Can a sub be deleted via macro?

Dan(?),

This will remove the macro named RemoveThisCode

Sub RemoveMacro()
' This shows how to remove a subroutine from a specific book / module
Dim myLineStart As Long
Dim myLineCount As Long
On Error GoTo NotFound:
With Application.Workbooks("VBA Code Examples.xls").VBProject.VBComponents("VBAStuff"). CodeModule
myLineStart = .ProcBodyLine("RemoveThisCode", vbext_pk_Proc)
myLineCount = .ProcCountLines("RemoveThisCode", vbext_pk_Proc)
.DeleteLines myLineStart, myLineCount
End With
NotFound:
End Sub

This code requires a reference to MS VBA Extensibility - and it may be flagged as a virus and
automatically deleted by many scanning packages.

HTH,
Bernie
MS Excel MVP


"danhattan" wrote in message
...
In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Can a sub be deleted via macro?

Thanks, Bernie.

Was going to try this, but don't see any of the following in the list of
References under the Tools menu: Extensibility, MS VBA Extensibility, VBA
Extensibility. Were you possibly referring to something else?

And yes, it is Dan. Used to live in NYC. Thanks again.

"Bernie Deitrick" wrote:

Dan(?),

This will remove the macro named RemoveThisCode

Sub RemoveMacro()
' This shows how to remove a subroutine from a specific book / module
Dim myLineStart As Long
Dim myLineCount As Long
On Error GoTo NotFound:
With Application.Workbooks("VBA Code Examples.xls").VBProject.VBComponents("VBAStuff"). CodeModule
myLineStart = .ProcBodyLine("RemoveThisCode", vbext_pk_Proc)
myLineCount = .ProcCountLines("RemoveThisCode", vbext_pk_Proc)
.DeleteLines myLineStart, myLineCount
End With
NotFound:
End Sub

This code requires a reference to MS VBA Extensibility - and it may be flagged as a virus and
automatically deleted by many scanning packages.

HTH,
Bernie
MS Excel MVP


"danhattan" wrote in message
...
In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Can a sub be deleted via macro?

Dan,

Look for Microsoft Visual Basic for Applications Extensibility. The file is this:

C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB

HTH,
Bernie
MS Excel MVP


"danhattan" wrote in message
...
Thanks, Bernie.

Was going to try this, but don't see any of the following in the list of
References under the Tools menu: Extensibility, MS VBA Extensibility, VBA
Extensibility. Were you possibly referring to something else?

And yes, it is Dan. Used to live in NYC. Thanks again.

"Bernie Deitrick" wrote:

Dan(?),

This will remove the macro named RemoveThisCode

Sub RemoveMacro()
' This shows how to remove a subroutine from a specific book / module
Dim myLineStart As Long
Dim myLineCount As Long
On Error GoTo NotFound:
With Application.Workbooks("VBA Code Examples.xls").VBProject.VBComponents("VBAStuff"). CodeModule
myLineStart = .ProcBodyLine("RemoveThisCode", vbext_pk_Proc)
myLineCount = .ProcCountLines("RemoveThisCode", vbext_pk_Proc)
.DeleteLines myLineStart, myLineCount
End With
NotFound:
End Sub

This code requires a reference to MS VBA Extensibility - and it may be flagged as a virus and
automatically deleted by many scanning packages.

HTH,
Bernie
MS Excel MVP


"danhattan" wrote in message
...
In the event that a subroutine becomes obsolete due to changes in the
spreadsheet data, can the sub be deleted/erased automatically as another sub
detects the reasons for the obsolescence?

If anyone has insight into this, much thanks.








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
deleted text character returning numbers when deleted. Trreborr09 New Users to Excel 3 April 11th 10 03:17 AM
Workbook still says there's a macro even though it's deleted Venus Excel Discussion (Misc queries) 1 April 2nd 09 05:06 PM
Macro deleted but still asking to enable? Jane Doe[_3_] Excel Worksheet Functions 5 September 23rd 08 05:58 PM
Macro deleted ALL data!! Angel the Secretary Excel Discussion (Misc queries) 4 August 6th 08 09:23 PM
Macro Deleted Jean-Francois Excel Discussion (Misc queries) 1 January 12th 05 03:12 PM


All times are GMT +1. The time now is 12:39 PM.

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

About Us

"It's about Microsoft Excel"