+ Reply to Thread
Results 1 to 6 of 6

Use New Workbook as Userform Output

  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Use New Workbook as Userform Output

    I need help creating the code for a userform that will generate a new workbook into which the userform data will go each time the userform is filled out anew.

    Also, is it possible to name the new workbook using data from the userform?

    I am teaching myself VBA as I go (so speak slowly...) and possibly biting off more than I can chew, but I've been Googling all day making only a little bit of headway. A bit of help with the code would help save me a ton of time at work. Thanks!

  2. #2
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Use New Workbook as Userform Output

    Can you provide a sample workbook with the userform. Will the new workbook be created each time the userform's submit button is clicked?

  3. #3
    Registered User
    Join Date
    09-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Use New Workbook as Userform Output

    I actually figured out how to do what I wanted to, only now I'm having a different issue. I'm not sure why it isn't working properly, because earlier in the day I seemed to have no trouble. I thought perhaps as I'd been going through trying this and that that I might have changed something to make it not work, but I had copied my 'working' code into a word doc once I figured it out so I'd have it saved in case I messed anything up, and incidentally it all still matches what's currently in VBA, so I'm not sure what is causing it to not work.

    In any case, this is the code I am using, and so far everything is functioning as it should, except for the ChDir - it is saving to my desktop and not the specified folder.


    ------------------------------------------------


    Private Sub submitbutton_Click()


    'Checking for input

    If Me.custnamebox.Value = "" Then
    MsgBox "Please Enter Customer Name", vbExclamation, "Customer Name"
    Me.custnamebox.SetFocus
    Exit Sub
    End If

    If Me.projnamebox.Value = "" Then
    MsgBox "Please Enter Project Name", vbExclamation, "Project Name"
    Me.projnamebox.SetFocus
    Exit Sub
    End If

    If Me.jobnobox.Value = "" Then
    MsgBox "Please Enter Job Number", vbExclamation, "Job Number"
    Me.jobnobox.SetFocus
    Exit Sub
    End If

    If Me.sysqtybox.Value = "" Then
    MsgBox "Please Enter Systems Quantity", vbExclamation, "Systems Quantity"
    Me.sysqtybox.SetFocus
    Exit Sub
    End If


    'writing input to cells


    Set newbook = Workbooks.Add("C:\Users\kate\Desktop\new summary template.xltm")

    ChDir "J:\Dumpster-Veyor\DV Summary"

    With newbook
    .SaveAs Filename:=Me.jobnobox.Value
    Dim ws As Worksheet
    Set ws = Worksheets("Summary")



    ws.Cells(1, 6).Value = Me.projnamebox.Value
    ws.Cells(3, 2).Value = Me.custnamebox.Value
    ws.Cells(4, 2).Value = Me.jobnobox.Value
    ws.Cells(5, 2).Value = Me.sysqtybox.Value

    End With


    Unload Me

    End Sub

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Use New Workbook as Userform Output

    Use the full path and filename in the SaveAs.

    PS Can you add code tags?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    09-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Use New Workbook as Userform Output

    sorry about that.

    i want to be able to use data from the userform to name each new workbook - how would i combine the path with the variable file name?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Use New Workbook as Userform Output

    All you need to do is add the path here.
    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. Userform help: optionnal output
    By edtrash in forum Excel General
    Replies: 5
    Last Post: 12-10-2012, 11:30 AM
  2. Output Data from a Userform to a txt file
    By jason_kelly in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-15-2010, 09:50 AM
  3. Userform output to worksheet: row movement
    By ilovelagar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-24-2009, 05:33 PM
  4. is it possible to link the output of userform to different workbook
    By sivdin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2009, 09:46 AM
  5. userform output to procedure
    By shellshock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2005, 06:31 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