简体   繁体   中英

VBA user form closing causes excel to hang

I'm having an issue here with a macro causing excel to hang. I've tried several options and searched endlessly. I have 3 forms, but separate. Here's my steps in it:

  1. Userform pops up
  2. Item from listbox is double clicked in the form.
  3. That opens another workbook and runs code on each sheet.
    • (This is done in another function and works perfectly and takes about 15 seconds ending with the focus on the new workbook.)
  4. Closes the userform. (This causes it to hang from 7 seconds to 90 seconds depending on the other workbooks size.)

Code below (please excuse the improper format, I had to use my phone... can't login via computer.)

Private sub lb_blah_DblClick (Byval Cancel as MSForms.ReturnBoolean)
  Me.lbl_blah2.caption = "opening aND running"
  'Open and edit xls - Works fine.
  LoadAndFormat me.lb_blah.value

  Me.lbl_blah2.caption = "Ran through format."
  Me.repaint

  '90 seconds with 29 sheets
  'Me.hide
  'Application.enableevents = false '70 seconds

  Unload me '90 seconds - 29 sheets

End Sub

I restarted my computer, and that seemed to fix it. I'm sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM