Results 1 to 7 of 7

VBA works 1st time, crashes the next

Threaded View

  1. #1
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    VBA works 1st time, crashes the next

    Hi All,

    If I open the spreadsheet and run this code it works perfectly.
    If I run it again, excel crashes.

    Any idea?

    Sub Import()
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    Dim MySheetName2 As String
    MySheetName2 = Sheets("Main").Range("C37").Value
    
    Dim Importsheet As Worksheet
    Sheets.Add Type:= _
    "C:\Users\bxr008\Desktop\Volatility Surface\DataFiles\" & MySheetName2 & "_Data.xlsx"
    
    Call CopySheet2
    Call Sheets(MySheetName2).Update
    
    Sheets(MySheetName2).Delete
    Sheets(MySheetName2 & "_Data").Delete
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    
    End Sub
    Thanks
    Last edited by tejay; 08-21-2015 at 08:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Code works but crashes half the time
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-11-2014, 02:59 PM
  2. [SOLVED] Macro crashes excel each time it is run
    By amotto11 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-05-2013, 06:34 AM
  3. Macro works....but CRASHES!
    By cbw123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2013, 09:05 PM
  4. Code works in Windows excel 2003 and 2010 but crashes in Mac excel 2011
    By kiweed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2012, 08:46 PM
  5. [SOLVED] Userform1 runs, all code works as it is required, but when i close it, Excel crashes
    By Spyderz in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-28-2012, 02:34 PM
  6. [SOLVED] Macro works but crashes Excel 2010
    By Willardio in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-09-2012, 08:49 AM
  7. Macro crashes from time to time when running from another computer
    By Kelshaer in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-31-2012, 09:12 AM
  8. Code Crashes Excel 2010 but works in Excel 2003
    By aaronf316 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2011, 03:46 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