+ Reply to Thread
Results 1 to 3 of 3

Macro to Rename Workbook & Delete Old workbook not working

  1. #1
    Registered User
    Join Date
    03-11-2020
    Location
    Melbourne, Australia
    MS-Off Ver
    2016
    Posts
    9

    Macro to Rename Workbook & Delete Old workbook not working

    Hi All

    Thanks for the help in advance. I have been pulling my hair out and wanted to avoid bothering the forums, but really need help. Can anyone identify the issue with this macro? Its included in Sheet1. The intention is to rename the workbook based on the contents in C7, and delete the old workbook.

    Please Login or Register  to view this content.
    Please note the "StopInput (Target)" is another sub in sheet1

    The issues I am having are:
    1. The worksheet_change wont call the sub RenameWorkbook when the contents in Cell C7 are updated
    2. I get error 70: permission denied, and the old workbook wont be deleted


    Thanks in advance
    Last edited by pascawali; 02-01-2023 at 02:51 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Macro to Rename Workbook & Delete Old workbook not working

    You are closing the file running this code, then expecting the code to continue running. I have never tried that but I would be surprised if it worked. The better strategy is to save with a new name then kill the original file. This version leaves the newly saved file open. You can close it if you want as the very last action in the code but it's not necessary.

    Also Target.Address gives a String with the address, but you are comparing it to a Range. You have to compare it to a String.

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-11-2020
    Location
    Melbourne, Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Macro to Rename Workbook & Delete Old workbook not working

    Thank you 6stringjazzer! That makes complete sense and thank you for the explanation, code is now working.

+ 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] Macro - Delete Sheets in Workbook and Rename Sheet per Cell Reference
    By cvici in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2021, 06:13 AM
  2. Macro to paste formatting only Excel 2013 - not working from workbook to workbook
    By LindyParsnips in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2016, 08:32 AM
  3. Replies: 0
    Last Post: 02-06-2015, 04:50 PM
  4. Replies: 0
    Last Post: 07-24-2014, 09:11 AM
  5. Macro to rename workbook
    By kaffal in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-14-2013, 01:27 AM
  6. copy sheets to new workbook with new name, rename tabs within that workbook
    By Conky4 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2012, 04:44 PM
  7. rename a workbook using a macro
    By Jamesmsv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2006, 11:00 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