Results 1 to 5 of 5

Naming exported file

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2015
    Location
    Slovakia
    MS-Off Ver
    2007, 2010, 2013
    Posts
    76

    Naming exported file

    Hello, i´ve got this code to save worksheet2 as new excel file. Is it possible to automatically name that exported file from value in choosen cell?

    For example if A1="Henry´s list" then file name will be named "Henry´s list". Thanks for answer.




    Sub testRenameSheets()
    Dim stFileName As String
    stFileName = Selection.Value
    Worksheets("Sheet2").Copy 'Creates a new workbook with the sheet.
    With ActiveSheet.UsedRange
    .Copy
    .PasteSpecial xlValues
    .PasteSpecial xlFormats
    End With
    Application.CutCopyMode = False
    Range("A1").Select
    stFileLocation = Application.GetSaveAsFilename(InitialFileName:=stFileName)
    ActiveWorkbook.SaveAs Filename:=stFileLocation & "xlsx"
    ActiveWorkbook.Close Savechanges:=False
    End Sub
    Last edited by jj4jj; 07-15-2015 at 01:31 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. need help with automatic filtration on exported file
    By akandl in forum Excel General
    Replies: 0
    Last Post: 07-31-2014, 03:50 PM
  2. Folder naming + File naming
    By Frozt15 in forum Excel General
    Replies: 2
    Last Post: 07-23-2012, 04:52 AM
  3. Counting errors from an exported file
    By Nalleman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-09-2011, 09:02 AM
  4. Data Exported From One Excel File To Another
    By willh3 in forum Excel General
    Replies: 5
    Last Post: 02-25-2007, 05:10 PM
  5. [SOLVED] How do you delete an exported file from a directory
    By Brett Smith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2006, 11:50 AM
  6. [SOLVED] VBE References Missing from Exported File
    By Stratuser in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2005, 12:06 PM
  7. [SOLVED] why are there quotes in my exported text file?
    By AlexK in forum Excel General
    Replies: 2
    Last Post: 02-16-2005, 03:04 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