Consulting

Results 1 to 3 of 3

Thread: How to dynamically place a VBA code to a Output excel file?

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location

    How to dynamically place a VBA code to a Output excel file?

    The VBA code creates multiple files from input file. I would like to dynamically place a VBA code in each output file.

    When "input.xlsm" (attached) code executes , it creates (a) Craig Smith.xls (2 tabs - Summary and detail) (b) Kelly Davis.xls (2 Tabs-Summary and detail) . The end product should look like "1Kelly Davis.xlsm" and "1Craig Smith.xlsm" . I place the code under "summary" module in "1Kelly Davis.xlsm" and "1Craig Smith.xlsm" files.

    Any suggestion.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi there,

    Rather than creating a new workbook and adding code to one of the sheet modules, you would likely find it easier to simply add a sheet to the source workbook. Then add the code to this "template" sheet's module. You can then create a new workbook by copying the sheet to a new workbook and you already have the code in it.

    Hope that helps,

    Mark

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Did you consider

    Sub M_snb()
       if Thisworkbook.name= "input.xlsm" then thisworkbook.savecopyas "G:\OF\1Craig Smith.xlsm"
    End sub

Posting Permissions

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