+ Reply to Thread
Results 1 to 4 of 4

Auto Rename Worksheet Before Closing

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Auto Rename Worksheet Before Closing

    Hello All,

    I need a VBA which will rename my existing excel workbook based on cell value/text; however this should be done automatically (macro should automatically run before closing the excel sheet).

    Also note I need to save the current excel workbook on same path but just with different name so i does not need multiple workbooks.

    Can this be done?

    Sandeep

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Auto Rename Worksheet Before Closing

    in your file (excel 2007)
    click developer
    click vbeditor (lefternmost)
    hit control+R
    all open filed will be listed
    go to your file
    select "thisworkbook"
    right and click view code
    in the window that opens copy this EVENT CODE and save the file

    Please Login or Register  to view this content.
    this will save the file in the same folder of this workbook with the name given by you
    I am not an expert. better solutions may be available
    [email protected]

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Auto Rename Worksheet Before Closing

    Hi, venkat1926,

    this will save the file in the same folder of this workbook with the name given by you
    I doubt no as you should use a different variable for the string as path which is a VBA Keyword. A trailing s indicates a collection while the normal would be String. Last: ThisWorkbook.Path holds the path excluding the final pathseparator.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Auto Rename Worksheet Before Closing

    Hello Both,

    Thank you so much! It worked!

    Hahobe: your trick of saving file with date and time is simply awesome, added reputation!

+ 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. Excel 2007 : Auto Uppercase on closing
    By Speculati0n in forum Excel General
    Replies: 2
    Last Post: 09-21-2011, 09:50 AM
  2. Auto Email when Closing
    By excelgrrl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2010, 09:13 AM
  3. VBA code auto load and auto closing
    By paraxis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-21-2008, 04:54 PM
  4. Help with auto macro on closing
    By mr_teacher in forum Excel General
    Replies: 3
    Last Post: 05-17-2006, 08:15 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