+ Reply to Thread
Results 1 to 3 of 3

Cannot delete a worksheet when a change event for a userform combobox detects rename sheet

  1. #1
    Registered User
    Join Date
    12-13-2019
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    2

    Exclamation Cannot delete a worksheet when a change event for a userform combobox detects rename sheet

    In the attached workbook, there is a modeless userform which has a combox with a rowsource pointing to the first worksheet "Sheet1!$B$1:$B$2".

    I have added a change procedure (event) to the combox, so that if a combox value changes, this will be triggered and the second worksheet will be deleted.

    What is good about this event, is that when you rename/delete any worksheet inside the workbook this event will be triggered. However, in this case, I am getting the following errors when it wants to delete the second worksheet:

    Run-time error '1004':
    Delete method of Worksheet class failed

    When I press End button on the error message, the following error is thrown:
    ---------------------------
    Microsoft Visual C++ Runtime Library
    ---------------------------
    Runtime Error!

    Program: C:\Program Files\Microsoft Office\Office14\EXCEL.EXE

    R6025

    - pure virtual function call

    Any help to resolve this issue is appreciated. The code is also given below:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Cannot delete a worksheet when a change event for a userform combobox detects rename s

    could not replicate your problem
    did not add any sheets, tried four times, all it did was delete the second sheet each time.
    Attached Images Attached Images

  3. #3
    Registered User
    Join Date
    12-13-2019
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    2

    Re: Cannot delete a worksheet when a change event for a userform combobox detects rename s

    Thank you so much for your reply.
    Did you also try creating a new worksheet and renaming it?
    In my case, it only works fine if I select items from the combobox. I am getting this error on Excel 2010. I will try on other Excel versions and update the post.

+ 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. Trigger worksheet change event when send data to sheet using userform
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2018, 02:14 PM
  2. Is It Possible to Refresh A Userform Using Worksheet Change Event
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2017, 10:01 AM
  3. [SOLVED] Dont trigger code if i delete some value from range Worksheet change event
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2017, 07:48 AM
  4. ComboBox in USERFORM used to change which sheet output goes
    By InvalidTxtString in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2016, 06:31 PM
  5. Replies: 7
    Last Post: 08-06-2013, 02:23 PM
  6. [SOLVED] UserForm ComboBox Change Event Question
    By tja1964 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2012, 07:21 PM
  7. MsgBox in Enter event causes combobox not to run Change event
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2006, 10:55 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