+ Reply to Thread
Results 1 to 6 of 6

Exporting Worksheets as xlsm with Values not Formulas

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Exporting Worksheets as xlsm with Values not Formulas

    I am using an export code to take my worksheets to a destined folder in xlsm format. I am looking to adjust this formula so when the worksheets are exported it is a flat file that just contains the values in the cells NOT the formulas.

    Sub CreateWorkbooks()Dim wbDest As Workbook
    Dim wbSource As Workbook
    Dim sht As Object 
    Dim strSavePath As String
    
    
    On Error GoTo ErrorHandler
    
    
    Application.ScreenUpdating = False 
    
    
    strSavePath = "S:\Test\" 
    
    
    Set wbSource = ActiveWorkbook
    
    
    For Each sht In wbSource.Sheets
    sht.Copy
    Set wbDest = ActiveWorkbook
    wbDest.SaveAs strSavePath & sht.Name
    wbDest.Close 
    Next
    
    Application.ScreenUpdating = True
    
    Exit Sub
    Thanks guys

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Exporting Worksheets as xlsm with Values not Formulas

    Try this:

    Sub CreateWorkbooks()
    Dim wbDest As Workbook
    Dim wbSource As Workbook
    Dim sht As Object
    Dim strSavePath As String
    Dim r As Long, c As Long, ws As Worksheet
    On Error GoTo ErrorHandler
    
    Application.ScreenUpdating = False
    
    
    strSavePath = "S:\Test\"
    
    
    Set wbSource = ActiveWorkbook
    
    
    For Each sht In wbSource.Sheets
    r = sht.Rows.Find("*", , , , xlByRows, xlPrevious).row
    c = sht.Columns.Find("*", , , , xlByColumns, xlPrevious).column
    sht.copy
    Set ws = ActiveSheet
    ws.Range("A1").Resize(r, c).value = sht.Range("A1").Resize(r, c).value
    Set wbDest = ActiveWorkbook
    wbDest.SaveAs strSavePath & sht.name
    wbDest.Close
    Next
    
    Application.ScreenUpdating = True
    
    ErrorHandler:
    
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Re: Exporting Worksheets as xlsm with Values not Formulas

    I keep getting a compile error expecting End Sub with the one above^^

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Exporting Worksheets as xlsm with Values not Formulas

    Hi JP,

    End Sub is there - did you copy the entire post?

  5. #5
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Re: Exporting Worksheets as xlsm with Values not Formulas

    Thanks dep

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Exporting Worksheets as xlsm with Values not Formulas

    You're welcome and thanks for the rep!

+ 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. [SOLVED] Converting formulas to values while copying/pasting columns between worksheets (vba)
    By macrorookie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2014, 11:55 AM
  2. Replies: 0
    Last Post: 01-29-2014, 07:38 AM
  3. [SOLVED] Exporting columns into new workbook as text values not formulas
    By ryanexceln00b in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-31-2013, 08:37 AM
  4. Converting formulas from .xls to .xlsm
    By Gianni10 in forum Excel General
    Replies: 2
    Last Post: 11-29-2011, 07:02 PM
  5. [SOLVED] Exporting values from many worksheets
    By dreamkeeper in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-30-2006, 06:50 PM

Tags for this Thread

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