+ Reply to Thread
Results 1 to 2 of 2

Exporting all Formulas and Code used in a Workbook

  1. #1
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Exporting all Formulas and Code used in a Workbook

    Morning,

    I'm busy making a portfolio of some projects I've done in Excel.

    Is there a way of exporting a list of all Code and Formulas used rather than copying and pasting every single variation?

    Cheers

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Exporting all Formulas and Code used in a Workbook

    Short of making a copy of the workbook, you're not going to be able to get everything.

    However, at least for code in "regular" modules, you can save the modules to BAS Files. The BAS files are text files of the module with a bit extra information included such as the module name and keyboard shortcuts.

    First, give you module a meaningful name. Personally, I keep the "mod" prefix although I'm not sure why. But I have modules like ModMailer and ModClearTable. I generally have the code in subroutines that can accept arguments passed to them so all I have to do is import the module and call it from my main code as opposed to modifying the module itself. Also I will include "like" functions in the same Module. For example, my ModClearTable module has two main subroutines: ClearTable which calls ClearFilter so both subroutines are available in the same package.

    Select the module and then File -> Export. Navigate to where you want to save the modules. I have a Folder Called MyExcel in my home directory. Excel "remembers" the last accessed folder so it's usually pointing to this directory when I export or import a module. To import a module, open the VB editor and select File -> Import.

    This technique only works with "regular" modules and Excel forms. Code embedded on sheets don't work this way. The only way I can think of doing that is to make a "template" out of the workbook with the data removed. You could, in code, open the template and copy the sheet to the target workbook.

    As for formulas I have a "cheat sheet." For example, if I need to find the last occurrence of a value in the range, I look at the sheet posted on the wall next to my computer: =MAX((Range=Value)*(ROW(Range)) - I have to "know" that this is an array formula.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. Macro exporting values/formulas into new workbook
    By allheilyb1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2016, 09:10 PM
  2. Exporting Workbook without Macro/Formulas
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2015, 03:50 PM
  3. Deleting specific code in formulas that are repeated across the workbook.
    By rob_bor5 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-08-2014, 05:03 AM
  4. Error when executing VBA code to remove all formulas from Workbook
    By brharrii in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-17-2013, 05:17 PM
  5. [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
  6. VBA code to paste formulas from workbook to workbook
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2012, 08:03 PM
  7. Replies: 0
    Last Post: 08-19-2010, 03:44 AM

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