+ Reply to Thread
Results 1 to 8 of 8

How to create a save button with vba

  1. #1
    Registered User
    Join Date
    05-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    How to create a save button with vba

    Ok I am completely new to excel and I was wondering if anyone knows how to save A worksheet as a new workbook with the naming convention: SheetName_(CustomerNo_DD.MM.YYYY). Is it possible for this to be accomplished through vba?


    Thank you to anyone that can help me.
    Last edited by Rob1236; 05-10-2013 at 02:47 PM.

  2. #2
    Forum Contributor
    Join Date
    05-08-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    102

    Re: Save Button

    You say that you wish to save a worksheet (as opposed to an entire existing workbook) as a new workbook. If you wish to save just this worksheet as a new workbook, what you can do is to right click on the sheet name tab, select the "Move or Copy" option, and in the dropdown menu, select the option that asks that Excel create a new copy onto a new workbook. Then you can save this new workbook as its own file with the naming convention that you stated.

    Note: You should be aware that if there are any formulas on the sheet you are trying to save as a new workbook, then it might be better to just go to the File menu and select "Save As" (after which you can save as your new naming convention).

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Save Button

    Hi and welcome to the forum

    We would love to help you with your question, but 1st, in accordance with forum rule, please rename your thread to something more meaningful, that actually describes your problem.

    Because thread titles are used in searching the forum it is vital they be written to accurately describe your thread content or overall objective using ONLY search friendly key words. That is, your title used as search terms would return relevant results.

    Also, many members will look at a thread title, and if it is of interest to them, or it falls within their area of expertese, they might only open those threads.

    Look at it this way...if you typed that title into google, what would you expect to get back?
    To change a Title on your post, click EDIT on you're 1st post, then Go Advanced and change your title
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    05-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Save Button

    hello, thanks for the advice I was in a rush when I created this thread so didnt have time to look at the forum rules (sorry!). Anyways I have renamed the thread.

  5. #5
    Registered User
    Join Date
    05-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Save Button

    Thank you for replying, your solution worked perfectly I was wondering if it was possible to do it via VBA? I have attempted it but it does not work correctly as I can't get the naming convention to appear.

  6. #6
    Forum Contributor
    Join Date
    05-08-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    102

    Re: Save Button

    You can do this through VBA. I recorded a macro just to see what the code looks like, cleaned up the code a bit, and here it is.

    Please Login or Register  to view this content.
    it worked for me. Let me know if it works for you. Once you get the sheet copied to a new workbook, then you can (manually) save it in accordance with your naming convention.
    Last edited by Dimitrov; 05-11-2013 at 01:15 AM.

  7. #7
    Registered User
    Join Date
    05-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to create a save button with vba

    You can do this through VBA. I recorded a macro just to see what the code looks like, cleaned up the code a bit, and here it is.


    Sub NewSheet()

    ActiveSheet.Copy

    End Sub
    it worked for me. Let me know if it works for you. Once you get the sheet copied to a new workbook, then you can (manually) save it in accordance with your naming convention.

    I tried your code and it worked great! much less complex than the code I was using, I added the following line to the code which it almost worked:

    Please Login or Register  to view this content.
    It seem to have worked before but for some reason it just stopped.

  8. #8
    Forum Contributor
    Join Date
    05-08-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    102

    Re: How to create a save button with vba

    I am not sure if this is what you are looking for, but the code below saves the file using the name of the active tab. It uses the name property of the ActiveSheet object. Of course, since I am using my own computer, the directory to which I am saving the file is C:\Users\Documents\VBA\Projects\005 - SaveAsSheetName\. You will have to key in the pathname of the directory in your computer in which you wish to save the file. The upshot is that you name your tab whatever you like, and the procedure saves the file using the name of the tab.


    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)

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