+ Reply to Thread
Results 1 to 66 of 66

Need VBA to create new Workbook and name it based on cell value in original file

Hybrid View

YukonSoDank Need VBA to create new... 04-07-2019, 03:40 PM
Mumps1 Re: Need VBA to create new... 04-07-2019, 04:09 PM
YukonSoDank Re: Need VBA to create new... 04-07-2019, 04:21 PM
YukonSoDank Re: Need VBA to create new... 04-07-2019, 04:36 PM
Mumps1 Re: Need VBA to create new... 04-07-2019, 04:44 PM
YukonSoDank Re: Need VBA to create new... 04-07-2019, 05:01 PM
Mumps1 Re: Need VBA to create new... 04-07-2019, 05:13 PM
YukonSoDank Re: Need VBA to create new... 04-07-2019, 05:34 PM
Mumps1 Re: Need VBA to create new... 04-07-2019, 07:36 PM
Mumps1 Re: Need VBA to create new... 04-09-2019, 09:28 AM
YukonSoDank Re: Need VBA to create new... 04-09-2019, 12:30 PM
Mumps1 Re: Need VBA to create new... 04-09-2019, 12:38 PM
YukonSoDank Re: Need VBA to create new... 04-09-2019, 01:03 PM
Mumps1 Re: Need VBA to create new... 04-09-2019, 01:07 PM
YukonSoDank Re: Need VBA to create new... 04-09-2019, 02:32 PM
YukonSoDank Re: Need VBA to create new... 04-09-2019, 07:54 PM
Mumps1 Re: Need VBA to create new... 04-10-2019, 10:32 AM
YukonSoDank Re: Need VBA to create new... 04-13-2019, 11:28 AM
Mumps1 Re: Need VBA to create new... 04-13-2019, 03:10 PM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 07:37 AM
Mumps1 Re: Need VBA to create new... 05-08-2019, 09:12 AM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 09:29 AM
Mumps1 Re: Need VBA to create new... 05-08-2019, 09:56 AM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 10:07 AM
Mumps1 Re: Need VBA to create new... 05-08-2019, 10:16 AM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 10:23 AM
Mumps1 Re: Need VBA to create new... 05-08-2019, 10:32 AM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 01:09 PM
Mumps1 Re: Need VBA to create new... 05-08-2019, 03:10 PM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 03:13 PM
Mumps1 Re: Need VBA to create new... 05-08-2019, 03:20 PM
YukonSoDank Re: Need VBA to create new... 05-08-2019, 08:31 PM
Mumps1 Re: Need VBA to create new... 05-09-2019, 08:13 AM
YukonSoDank Re: Need VBA to create new... 05-09-2019, 11:24 AM
Mumps1 Re: Need VBA to create new... 05-09-2019, 11:35 AM
YukonSoDank Re: Need VBA to create new... 05-09-2019, 08:59 PM
Mumps1 Re: Need VBA to create new... 05-10-2019, 08:32 AM
YukonSoDank Re: Need VBA to create new... 05-10-2019, 09:13 AM
Mumps1 Re: Need VBA to create new... 05-10-2019, 01:22 PM
YukonSoDank Re: Need VBA to create new... 05-13-2019, 07:25 PM
Mumps1 Re: Need VBA to create new... 05-14-2019, 10:11 AM
YukonSoDank Re: Need VBA to create new... 05-14-2019, 09:13 PM
Mumps1 Re: Need VBA to create new... 05-15-2019, 11:07 AM
YukonSoDank Re: Need VBA to create new... 05-30-2019, 10:24 AM
Mumps1 Re: Need VBA to create new... 05-30-2019, 11:43 AM
YukonSoDank Re: Need VBA to create new... 05-30-2019, 12:34 PM
Mumps1 Re: Need VBA to create new... 05-30-2019, 01:06 PM
YukonSoDank Re: Need VBA to create new... 05-30-2019, 01:44 PM
Mumps1 Re: Need VBA to create new... 05-31-2019, 09:37 AM
YukonSoDank Re: Need VBA to create new... 05-31-2019, 09:45 AM
Mumps1 Re: Need VBA to create new... 05-31-2019, 11:39 AM
YukonSoDank Re: Need VBA to create new... 05-31-2019, 01:15 PM
Mumps1 Re: Need VBA to create new... 05-31-2019, 02:25 PM
YukonSoDank Re: Need VBA to create new... 05-31-2019, 02:53 PM
Mumps1 Re: Need VBA to create new... 06-01-2019, 12:33 PM
YukonSoDank Re: Need VBA to create new... 06-01-2019, 03:28 PM
Mumps1 Re: Need VBA to create new... 06-02-2019, 07:49 AM
YukonSoDank Re: Need VBA to create new... 06-02-2019, 09:23 AM
Mumps1 Re: Need VBA to create new... 06-03-2019, 09:59 AM
YukonSoDank Re: Need VBA to create new... 06-08-2019, 02:47 PM
  1. #1
    Registered User
    Join Date
    04-02-2019
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    74

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    I've created a template file that replicates most of what I need:

    Dim strTemplate As String: strTemplate = "Path\template.xlsx"
    Dim wb As Workbook

    Set wb = Workbooks.Add(strTemplate)

    This works perfectly but I am not sure how to then cut and land the data into the newly-created workbook. It also obvi doesn't change the file name as I described earlier.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    Can you attach a copy of the template file? You can only change the name of the file when you save it. What is the full path to the folder where you want to save the new file? Is the template file in the same folder?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    04-02-2019
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    74

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    Dim strTemplate As String: strTemplate = "C:\Users\havenc\Desktop\Upwork\Model_Template.xlsx"
    Dim wb As Workbook

    Set wb = Workbooks.Add(strTemplate)

    Yes, they would be saved in the same folder.
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    I assume you want to copy the data from the "Outputs" sheet in Sched_Example to the "Input" sheet of the template starting in column P. If that is correct, the setup of the 2 sheets is different in that the "Input" sheet of the template has formulas in rows 6, 10 and 11. If we simply copy the data from the "Outputs" sheet in Sched_Example to the "Input" sheet of the template, the formulas will be overwritten. Could you please clarify in detail which rows of data you want to copy from the "Outputs" sheet and exactly where in the "Input" sheet you want to paste that data.

  5. #5
    Registered User
    Join Date
    04-02-2019
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    74

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    All apologies,

    => B12:M12 in "Sched_Example" would paste into Q4:AB4

    => B13:M13 in "Sched_Example" would paste into Q5:AB5

    => B14:M15 in "Sched_Example" would paste into Q8:AB9

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    Place this macro in a standard module in the Sched_Example workbook and run it from there.
    Sub CopyDataAndSave()
        Application.ScreenUpdating = False
        Dim desWB As Workbook, desWS As Worksheet, srcWS As Worksheet
        Set srcWS = ThisWorkbook.Sheets("Outputs")
        Set desWB = Workbooks.Open(Environ("userprofile") & "\Desktop\Upwork\Model_Template.xlsx")
        Set desWS = Sheets("Input")
        With srcWS
            .Range("B12:M13").Copy desWS.Range("Q4")
            .Range("B14:M15 ").Copy desWS.Range("Q8")
        End With
        ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & Application.PathSeparator & srcWS.Range("A3").Value & ".xlsx", FileFormat:=51
        Application.ScreenUpdating = True
    End Sub

  7. #7
    Registered User
    Join Date
    04-02-2019
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    74

    Re: Need VBA to create new Workbook and name it based on cell value in original file

    It doesn't like the file saving portion at the end. I've tried removing that part but I still get errors. How can I remove that step and keep the rest functioning?

+ 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. Replies: 5
    Last Post: 10-17-2018, 02:35 AM
  2. [SOLVED] Need to modify macro to also create backup of original file
    By tfilipe in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-15-2018, 03:25 PM
  3. open worksheet in a different workbook based on cell name in original workbook
    By thara95 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2017, 07:38 AM
  4. VBA that works perfectly in one file errors out in a new file based off the original!
    By carthesis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-09-2016, 07:24 AM
  5. Replies: 1
    Last Post: 07-17-2014, 12:06 PM
  6. Splitting Excel file but want to create data links to original
    By hitchy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2013, 11:46 AM
  7. Trying to create a 2nd workbook to mirror the first, to protect the original
    By zachdking in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2013, 08:11 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