+ Reply to Thread
Results 1 to 13 of 13

Clear All VBA Codes and formulas

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Moscow
    MS-Off Ver
    Office 365
    Posts
    100

    Re: Clear All VBA Codes and formulas

    Sub All_Formulas_To_Values_In_All_Sheets()
        Dim wsSh As Worksheet
        For Each wsSh In Sheets
            wsSh.UsedRange.Value = wsSh.UsedRange.Value
        Next wsSh
    End Sub
    And delete macro without reference to Extensibility 5.3 library:
    Sub DeleteAllVBACode()
            Dim VBProj As Object
            Dim VBComp As Object
            Dim CodeMod As Object
            
            Set VBProj = ActiveWorkbook.VBProject
            
            For Each VBComp In VBProj.VBComponents
                If VBComp.Type = 100 Then
                    Set CodeMod = VBComp.CodeModule
                    With CodeMod
                        .DeleteLines 1, .CountOfLines
                    End With
                Else
                    VBProj.VBComponents.Remove VBComp
                End If
            Next VBComp
    End Sub
    Also in Excel 2007 and higher you may save workbook as .xlsx. All macroses will be del
    I'm sorry my english...

  2. #2
    Forum Contributor
    Join Date
    10-16-2014
    Location
    Center Line, Michigan, United States
    MS-Off Ver
    MS Office 2013
    Posts
    139

    Re: Clear All VBA Codes and formulas

    Also, there's a modification to the code to also work on hidden sheets:

    Option Explicit 
     
    Sub Formula_Zapper_MkII() 
         
        Dim sh As Worksheet, HidShts As New Collection 
        For Each sh In ActiveWorkbook.Worksheets 
            If Not sh.Visible Then 
                HidShts.Add sh 
                sh.Visible = xlSheetVisible 
            End If 
        Next sh 
         
        Worksheets.Select 
        Cells.Select 
        Selection.Copy 
        Selection.PasteSpecial Paste:=xlPasteValues 
        ActiveSheet.Select 
        Application.CutCopyMode = False 
         
        For Each sh In HidShts 
             '        sh.Delete
            sh.Visible = xlSheetHidden 
        Next sh 
         
    End Sub
    Please click the star (add rep) if I helped!

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Clear All VBA Codes and formulas

    Quote Originally Posted by The_Prist View Post
    Sub All_Formulas_To_Values_In_All_Sheets()
        Dim wsSh As Worksheet
        For Each wsSh In Sheets
            wsSh.UsedRange.Value = wsSh.UsedRange.Value
        Next wsSh
    End Sub
    And delete macro without reference to Extensibility 5.3 library:
    Sub DeleteAllVBACode()
            Dim VBProj As Object
            Dim VBComp As Object
            Dim CodeMod As Object
            
            Set VBProj = ActiveWorkbook.VBProject
            
            For Each VBComp In VBProj.VBComponents
                If VBComp.Type = 100 Then
                    Set CodeMod = VBComp.CodeModule
                    With CodeMod
                        .DeleteLines 1, .CountOfLines
                    End With
                Else
                    VBProj.VBComponents.Remove VBComp
                End If
            Next VBComp
    End Sub
    Also in Excel 2007 and higher you may save workbook as .xlsx. All macroses will be del
    This is perfect .. Really fantastic Mr. the_prist

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Transpose Excel formulas to VBA codes
    By kraut in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-29-2013, 11:04 AM
  2. Clear static formulas, but leave linked formulas
    By pacerx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2013, 05:08 AM
  3. Using Formulas to Generate SKU codes
    By X-tremejoe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2013, 03:55 PM
  4. Using Formulas to Generate SKU codes
    By X-tremejoe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2013, 03:33 PM
  5. Creating VBA codes to do what formulas do
    By jacglc2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2010, 01:52 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1