Results 1 to 3 of 3
  1. #1

    Removing macros on certain dates..

    Is it possible to remove all macros in a workbook
    at the dates that we chose. Its like self destruction.
    I know how to remove all formulas on a certain dates but
    need to know how to removes macros.Any ideas..Refer to the
    code below for removing formulas on certain dates..

    Private Sub Workbook_Open()
    Dim Sht As Worksheet, i As Integer
    Dim AllFormulas As Range
    On Error Resume Next
    If Date > 37015 Then
    For Each Sht In ThisWorkbook.Worksheets
    Sht.Unprotect password:="1234"
    Set AllFormulas = Sht.Cells.SpecialCells(xlCellTypeFormulas)

    For i = 1 To AllFormulas.Areas.Count
    AllFormulas.Areas(i).PasteSpecial xlPasteValues
    Next i

    Set AllFormulas = Nothing
    Next Sht
    Application.CutCopyMode = False
    End If
    End Sub

    hope this possible. regards

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Dublin, Ireland, Republic of
    Thanked 0 Times in 0 Posts

    Re: Removing macros on certain dates..

    The follwoing line of code will delete Module1 in the active workbook. You cannot delete code from Thisworkbook or Worksheet etc using this procedure.

    <pre> ThisWorkbook.VBProject.VBComponents.Remove ThisWorkbook.VBProject.VBComponents("Module1")</pre>

    Why not just include a check for the date in your code and just exit sub if the date has passsed ?

    Andrew C

  3. #3

    Re: Removing macros on certain dates..

    Many thanks Andrew for the response and the ideas. Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts