+ Reply to Thread
Results 1 to 7 of 7

Save and Close Button on an excel userfom

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Save and Close Button on an excel userfom

    Having a hard time figuring out how to write a script for a "save and close button" on my userform. I need it to save in a certain location once the “save and closed” button is clicked. I also need it to close out the userform and to close out of excel. Any help would be greatly appreciated.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Save and Close Button on an excel userfom

    Hi,

    Put the name of the location in a cell somewhere, use this as a variable and name the cell "SavePath". End it with a "\" e.g. C:\Temp\

    Now attach the following macro to your form's save and close button

    Please Login or Register  to view this content.
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-21-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Save and Close Button on an excel userfom

    Thank you Richard.......does it matter if i have multiable worksheets with in my excel userform?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Save and Close Button on an excel userfom

    Hi,

    I'm not sure what you mean by worksheets in a user form. Can you clarify please.

    Rgds

  5. #5
    Registered User
    Join Date
    07-21-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Save and Close Button on an excel userfom

    Sorry about not been clear.

    I have 4 worksheet tabs within my excel spreadsheet. When the user opens the spreadsheet the userform is the only item they use to enter data (all the worksheets are hidden). I have the userform set to populate into worksheet tab (OrderLog). Once they have entered all the data the user clicks on "close form". Once they click on it I would like it to save (which I have working now) and close out of excel completely. Thanks again for your help. This site is VERY helpful.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Save and Close Button on an excel userfom

    Hi,

    To answer your original question, No it doesn't matter how many sheets you have. You are closing the whole Excel Application including the workbook you're using and any others that may happen to be open.

    I don't think it's relevant but I don;t know what you mean when you say all worksheets are hidden. There is always at least one worksheet open in a workbook. Are you really meaning workbooks are hidden?

    Regards

  7. #7
    Registered User
    Join Date
    07-21-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Save and Close Button on an excel userfom

    Again sorry.....very new at VBA.
    There is one workbook that is open that the user can see in the background. Its blank so that it looks clean to the user.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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