+ Reply to Thread
Results 1 to 13 of 13

Vba Code to copy the formula file as values and save it another location

  1. #1
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Vba Code to copy the formula file as values and save it another location

    Hi guys

    I have 20 excel workbook basically for different models each having 4 sheets .
    All 20 workbook is loads of formulas, i intend to send these workbooks to client as values.

    There will lot of back and forth communication once i send and i have alter lot of numbers after i send.

    Once all the file is final, is there any code where i can put it in all model workbook to basically save the first three sheet of workbook as values and get copied in one file location retaining the formula file as it is?

    So when i have to change the number again , ill change the numbers and run the macro.



    Thanks for any assistance

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    Sure - a simple macro will convert all the formulas to values:
    To convert all sheets in the activeworkbook to values:


    Please Login or Register  to view this content.
    To convert just the first 3 sheets to values

    Please Login or Register  to view this content.
    The add a SaveAs to either of these

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 07-31-2015 at 03:28 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    hi bernie thanks a lot...

    i have limited knowledge in vba..how do i combine all three as one code?
    and will it retain my original formula file?

    Thanks again

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    You would only use one of the first two, and one line form the last, like this - but this assumes the active workbook is an xlsx file, this macro resides in another file (like your personal.xlsb) and you need to change the folder path.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    hi its not working

    is it because of undeclared sh?
    and my active workbook is xlsm, wouldnt it work?

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    You need to have a valid path to save the file... what code are you using?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    Hi bernie

    U had used next sh, shouldnt it be next i?

    Thanks

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    D'oh! Sorry - you're correct: I copied and pasted the first one and did a bad job of editing the pasted code.

    Sub ConvertToValues5()
    Dim i As Integer

    For i = 1 To 3
    Worksheets(i).UsedRange.Value = Worksheets(i).UsedRange.Value
    Next i

    ActiveWorkbook.SaveAs "C:\Users\anzafsa\Excel\" & ActiveWorkbook.Name, 52 'xlsm and a valid path

    End Sub

  9. #9
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    No worries..
    However one small doubt bernie, if i want to modify the [Worksheets(i).UsedRange.Value = Worksheets(i).UsedRange.Value], say i want to exclude column f and g from copy paste as values, i want to retain those 2 columns as formula, rest everything as values, whats the code?

    Thanks

  10. #10
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    Please Login or Register  to view this content.
    could become:

    Please Login or Register  to view this content.

    or


    Please Login or Register  to view this content.
    The last one won't work if your data extends to within 6 columns of XFD....

  11. #11
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    Wow awesome bro....genius stroke!!

    Thanks a tonne.....

  12. #12
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Vba Code to copy the formula file as values and save it another location

    Hi.
    Please Login or Register  to view this content.
    This code doesnt give me the same number formats as the source file, ex:if i have '058 in my source file, if i run the macro it gets converted to 58.
    same with '00, '1E7 etc,
    can this code be modified to keep the same number formats after i run the macro?

    Thanks for any help

  13. #13
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Vba Code to copy the formula file as values and save it another location

    It should not change the formatting, but try

    Please Login or Register  to view this content.

+ 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. Need help with code to save file in a folder location based on a cell value
    By msantucci in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2015, 05:56 PM
  2. [SOLVED] Need code to copy data based on filter criteria to new workbook as save in a file location
    By msantucci in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2015, 02:47 AM
  3. Macro to Auto save a backup copy in a seperate location OR save file with a pop up
    By kdsanderson30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2014, 12:38 PM
  4. Copy, edit and save workbook to same location as source data file, not macro file.
    By Jasonhouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 09:01 AM
  5. [SOLVED] Macro to save a file to a certain location and name it after 2 cell values possible?
    By 33CDonnelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 07:57 PM
  6. Click a button, auto-save a copy of the .XLS file to a specified location?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2011, 12:45 PM
  7. Using Macro to Save Copy of File to New Location
    By Chris Z in forum Excel General
    Replies: 1
    Last Post: 07-05-2006, 12:20 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