+ Reply to Thread
Results 1 to 6 of 6

Clearing of listbox causing excel to crash

  1. #1
    Registered User
    Join Date
    12-14-2012
    Location
    Bratislava
    MS-Off Ver
    Excel 2003
    Posts
    3

    Clearing of listbox causing excel to crash

    Hello I have a code for clear normal Listbox in Excel(not active X, and not in userform). It worked on excel 2013, but I have moved to win 10 and using Office 365 64 bit now and for some reason when Vba tries to execute lbx.RemoveAllItems on non-empty listbox which has extended selections the excel crashes(but it works in single selection mode)
    original code:
    Please Login or Register  to view this content.
    what I also tried( and figured out that it always crashes when tries to remove last item in Lisbox and I know the index of last item is 1): I'll get "Run-Time error '1004':RemoveItem method of ListBox class failed" and then excel crashes again
    Please Login or Register  to view this content.
    Can anyone help plz?
    Last edited by vlad67; 09-14-2017 at 02:30 PM. Reason: fixing format

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Clearing of listbox causing excel to crash

    Maybe you need the index rather than 1

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Clearing of listbox causing excel to crash

    How are you populating the listboxes?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    12-14-2012
    Location
    Bratislava
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Clearing of listbox causing excel to crash

    basically it is lbx.addItem "some text"

  5. #5
    Registered User
    Join Date
    12-14-2012
    Location
    Bratislava
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Clearing of listbox causing excel to crash

    Quote Originally Posted by xladept View Post
    Maybe you need the index rather than 1

    Please Login or Register  to view this content.

    I have tried but after playing with it I figured out that last item always has index 1....it looks like when you delete item 1 the rest will move backwards so 3-->2 and 2-->1(so technically it seems you just need to delete index 1 multiple times if you don't use RemoveAllItems) ... however I finally found a way around it...I just set listboxes as single selection before removeAlllItems and then after I repopulate them I am able to set them as extended selection so people can choose multiple... this way it works...however don't understand why it crashes when I try to removeAllItems with extended selection when it worked on previous versions...hell even on colleague's Office 365 but win 7(so 32 bit) it works normally (it looks like it doesn't want me to have multiple or extended selection if listbox is empty...single selection is ok)
    Last edited by vlad67; 09-14-2017 at 03:52 PM.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Clearing of listbox causing excel to crash

    Sorry - that's all that occurred to me.

+ 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 causing excel to crash regularly
    By DavidBarker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2016, 08:04 PM
  2. Macro causing excel 2010 to crash
    By bradleyandrewdavis in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2015, 09:44 AM
  3. Macro causing excel to crash
    By bradleyandrewdavis in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-16-2015, 04:29 AM
  4. [SOLVED] object invoked error causing excel to crash
    By edopts in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-11-2014, 12:55 PM
  5. ClearContent Macro causing Excel crash.
    By Phily915 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2014, 12:54 PM
  6. VBA Macro Causing Excel To Crash - Can it Be More Efficient?
    By LoggersAW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2013, 08:49 PM
  7. Using Scroll Wheel on VB Listbox on Sheet causing crash
    By AndyHammer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2010, 05:43 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