+ Reply to Thread
Results 1 to 9 of 9

Imported file name as SHEET TITLE

  1. #1
    Registered User
    Join Date
    03-19-2010
    Location
    Estonia
    MS-Off Ver
    Excel 2016
    Posts
    25

    Imported file name as SHEET TITLE

    Hello,
    I have this VBA code that I partially recorded. Firstly it asks files to be imported and then puts each file into separate sheet.

    But how to get the currently connected file's name?
    I would like that each sheet has the file's name as title.

    For example if I import files: test1.csv, test2.csv, test3.csv
    Then I would like to have sheet names: test1, test2, test3

    To change sheet name, there is code:
    ActiveSheet.Name = "New Name"

    Here is my VBA code:
    Please Login or Register  to view this content.
    Last edited by fred123; 04-06-2017 at 05:16 AM.

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Imported file name as SHEET TITLE

    hi
    try replacing your blue line with this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-19-2010
    Location
    Estonia
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: Imported file name as SHEET TITLE

    not working, throws error

    At the moment (without renaming) it names the sheets like: Sheet1, Sheet2, Sheet3 ....
    But I would like the sheet names to be: test1, test2, datafile3, newdata, ...etc based on imported file name.
    Last edited by fred123; 04-06-2017 at 05:42 AM.

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Imported file name as SHEET TITLE

    try this instead

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-19-2010
    Location
    Estonia
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: Imported file name as SHEET TITLE

    I dont know, still nothing

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Imported file name as SHEET TITLE

    Try change that line to
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-19-2010
    Location
    Estonia
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: Imported file name as SHEET TITLE

    Thank you, but that gives me 'Type mismatch' error

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Imported file name as SHEET TITLE

    OOps
    try change fname to file

  9. #9
    Registered User
    Join Date
    03-19-2010
    Location
    Estonia
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: Imported file name as SHEET TITLE

    Nice!!!! Thanks a lot. Works like a Charm

+ 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. [SOLVED] Search a sheet for a song title and return Album title
    By A440 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-28-2016, 10:19 AM
  2. [SOLVED] inserting a timestamp on the data sheet when a raw data file is imported
    By macrorookie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2014, 02:18 PM
  3. [SOLVED] import every file in the folder and rename sheet to the imported file name
    By vivek_work in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-04-2012, 02:46 PM
  4. Rename sheet to match name of an imported file
    By Jackets in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2010, 01:41 PM
  5. How to rename sheet to match name of the imported file
    By GoJackets in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2010, 09:18 PM
  6. add imported text file name above imported data
    By tompie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2009, 08:18 AM
  7. Macro to name sheet with imported .CSV file name
    By MichielEngineer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2008, 06:42 AM

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