+ Reply to Thread
Results 1 to 4 of 4

Runtime 1004 Errors on Cancelling Macro

  1. #1
    Registered User
    Join Date
    01-31-2017
    Location
    Chester
    MS-Off Ver
    2013
    Posts
    26

    Runtime 1004 Errors on Cancelling Macro

    Hi, all

    I wonder if you can assist me in this issue.

    I have some code and it works fine for copying a worksheet and renaming it. BUT - if I cancel, it generates a Runtime 1004 error. Is there anything that has been missed in this code?

    I'd be profoundly grateful if anyone can assist me here.

    Here is the code:

    Sub CopySheet_rename()

    'assumming your active sheet is the one you want to copy

    currentName = ActiveSheet.Name
    CopyName = InputBox("Enter name of new Contractor: ")
    Sheets(currentName).Copy After:=Sheets(currentName)
    ActiveSheet.Name = CopyName
    End Sub

    Kind regards in advance,

    Jaime.
    Last edited by JaimeP; 02-01-2017 at 09:56 AM. Reason: [Solved]

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Runtime 1004 Errors on Cancelling Macro

    Hi,

    I presume you do not wish the sheet to be copied if you press Cancel on the inputbox? If that is correct then
    Please Login or Register  to view this content.
    blue line is the addition.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    01-31-2017
    Location
    Chester
    MS-Off Ver
    2013
    Posts
    26

    Re: Runtime 1004 Errors on Cancelling Macro

    Hi, there

    Thank you so much for your swift response. That has worked a treat.

    I didn't want to copy the worksheet on cancel, which unfortunately, it was doing. Now it works fine.

    Thank you so much again,

    Jaime.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Runtime 1004 Errors on Cancelling Macro

    You're welcome.

+ 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. macro used to work but now runtime error 1004
    By clammastak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2016, 03:22 PM
  2. keep getting Runtime error 1004 in my VBA Macro and not sure why
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2015, 04:29 PM
  3. [SOLVED] Cancelling Application.ontime Error 1004
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2015, 08:24 AM
  4. Runtime error 1004 using macro in excel 2007
    By CrazyHorse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2011, 11:54 AM
  5. How to handle this excel macro generation problems and runtime errors.
    By Ajain Ahan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2011, 07:24 AM
  6. Macro - Runtime Error 1004
    By Evian in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 10-08-2008, 04:54 AM
  7. Using a macro to put a function in a certain cell (runtime error 1004)
    By Juhanen II in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2007, 10:29 AM

Tags for this Thread

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