+ Reply to Thread
Results 1 to 13 of 13

VBA to copy sheet to new workbook, save as new name with the days date, and...

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    VBA to copy sheet to new workbook, save as new name with the days date, and...

    Good morning happy campers,

    I have a workbook (among many) it contains various sheets with command buttons to open, modify, save & close various other sheets.

    Current standing;-
    Work Book named "Updated Sheet"
    Saved in location - "W:\LOGISTICS\Supervisor's\Housekeeping\Updated Sheet.xlsm"
    On this workbook i have 6 tabs (some hidden some not), tab named "H.K Template" - on this tab i have a button that will set the print area to as many cells contain info, and a button to move (switch sheet) to another location.
    I would like a code that will;
    *Copy the "H.K Template" sheet ONLY from this workbook
    *Paste into new workbook
    *Delete all other tabs (so only the "H.K Template" is present)
    *Save as the name of the user logged into windows, and the days date - "Joe.Bloggs 30.06.12" into a location (to be defined later, so for now use address above)
    *Return to the workbook "Updated Sheet"
    *Clear cell contents all previously entered into ranges "C3:J23" & "A25:J33"
    Then save.

    Now, i have some experience with VBA, the sheet im using has buttons for opening new sheets, auto filtering etc. which i can just about understand well enough but i cant get my head round saving as new seperate sheet and using the name of the person logged into windows and the date.
    All help is appreciated

    Kind Regards, Galvinpaddy

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    as an option for first question..
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Hi Thanks for your input!
    An issue i encounter - i cant find where it saves
    I set the directory as "W:\LOGISTICS\Supervisor's\Housekeeping"
    but it is not there, yet when i save it again, it warns me it already exists

  4. #4
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Please Login or Register  to view this content.
    What (if anything) have i done wrong in the above?

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    search it with "Search programms and files" and see where it was saved...are you sure that yr path is a correct one?

  6. #6
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Sry, moment of idiocy ( i think) but it now appears

    Thank you very much indeed

  7. #7
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    As a hopefully final question to this thread - in my OP, the second part - i have added to your code -
    Please Login or Register  to view this content.
    to clear all the contents, can i tidy this up or should this be ok?

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    try this
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Stuff of legends, thanks very much indeed.
    Well deserved REP added

    galvinpaddy

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Glad I helped you!

  11. #11
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Quote Originally Posted by john55 View Post
    as an option for first question..
    Please Login or Register  to view this content.
    Hi John, if i could ask what the following line in your code does??
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    Hello!
    in yr code, that line does not do anything because at the beginning is an apostrophe, else a new sheet named "testsheet" is added.
    make a test, delete that apostrophe and see!

  13. #13
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    869

    Re: VBA to copy sheet to new workbook, save as new name with the days date, and...

    haha, lovely thanks

+ 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