Updated – Archive version of spreadsheet without formula

Earlier, I mentioned how I was creating an archive copy of a workbook.

I found a more efficient way of doing things that works a lot faster, and is a whole lot less code

Sub SaveFileWithoutFormulas()
  
    If SaveWorkbook Then       
        Dim wsCounter As Long
        Dim ws As Worksheet
        
        For wsCounter = 1 To ThisWorkbook.Worksheets.Count
            Set ws = Nothing
            Set ws = Sheets(wsCounter)
            Sheets(wsCounter).Select
            
            If ws.AutoFilterMode Then
                Application.ActiveSheet.ShowAllData
            End If
            
            Cells.Select
            Selection.Copy
            Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
                xlNone, SkipBlanks:=False, Transpose:=False
        Next wsCounter    
    End If    
End Sub

Function SaveWorkbook()
    On Error GoTo ErrHandler:
    Dim workBookName As String
    workBookName = Replace(ThisWorkbook.Name, ".xls", "_")
    workBookName = workBookName & Format(Date, "ddmmmmyyy") & ".xls"
    
    ActiveWorkbook.SaveAs Filename:= _
        workBookName _
        , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
    SaveWorkbook = True
    Exit Function
    
ErrHandler:
    SaveWorkbook = False
End Function
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
This entry was posted in Uncategorized. Bookmark the permalink.