+ Reply to Thread
Results 1 to 2 of 2

VBA to name the copied worksheet with designated name and name on worksheet tab

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2007
    Posts
    51

    VBA to name the copied worksheet with designated name and name on worksheet tab

    Hi,

    I'm running into a wall. I created vba code that will copy a sheet from my main workbook, create a new workbook and now I need to save it using the name I provide plus the name of the worksheet (which is the date). So the name of the file would look like My new workbook 3.8.19.xls

    Any help would be greatly appreciated! Thank you Bev

    I'm getting an error at the save as step
    Sub copyworksheet2newworkbook()

    Dim FName As String
    Dim ShtName As String
    Dim FPath As String
    Dim NewBook As Workbook
    Dim TDate As String

    FPath = "C:\Users\v-begrov\Desktop\"
    ShtName = ActiveWorkbook.Name
    FName = "My New file name" & TDate.xls"


    Range("Cela_Export").Copy
    Set NewBook = Workbooks.Add
    Sheets.Add.Name = Format(Date, "mmm-dd-yy")

    With NewBook.Sheets(1).Range("A2:O100")
    ActiveSheet.Paste
    Cells.Select
    Range("A2").Activate
    Cells.EntireColumn.AutoFit
    Cells.Select
    ActiveWindow.Zoom = 75
    .SaveAs Filename:=FPath & ShtName
    .Close



    End With

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,630

    Re: VBA to name the copied worksheet with designated name and name on worksheet tab

    So what doesn't the code you have do that it needs to do ... what is your issue?


    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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: 7
    Last Post: 04-11-2018, 11:17 PM
  2. Data (Drop Down) Value in 1 Worksheet / Copied-Updated to Another Worksheet
    By SMurtagh in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-30-2016, 01:28 PM
  3. [SOLVED] Copied check boxes contain worksheet reference to source worksheet
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2015, 03:53 PM
  4. Replies: 2
    Last Post: 12-15-2014, 06:34 PM
  5. Copy data from a copied worksheet to another worksheet based on cell reference
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2013, 02:18 PM
  6. Copying multiple worksheet so that copied hyperlinks link to new copied sheets
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2013, 02:37 PM
  7. info/data transferred/copied from worksheet to worksheet in same workbook!
    By joe dech in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-17-2012, 02:53 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