why is this code crashing? happened suddenly....

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
Code:
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
   

    start_dates
   
    'make folders for RAW

   
       p1 = ThisWorkbook.Path & "\Raw Data\"
       
   If Len(Dir(p1 & fiscal_year, vbDirectory)) = 0 Then
     
    MkDir (p1 & fiscal_year)
   
    End If
   
   
       p2 = p1 & fiscal_year
       
    
       
        '
       
      Range("save_raw") = "DONE!"
     
     


'To copy Raw Data to rawdata - MMMM
   
    'if report date is the same as the first business day of the month then make a new monthly file
   

    If Range("reportdate") = Range("fom") Then
   
  

    Sheets("RawData").Copy
   
    ActiveWorkbook.SaveAs Filename:= _
        p2 & "\RawData - " & show_Month_long & " " & show_Year & ".xlsb" _
        , FileFormat:=50
       
    ActiveSheet.Name = format(Range("ReportDate"), "mmm DD")
     
 ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1


        Else
       
   
   Set raw = Workbooks.Open(p2 & "\RawData - " & show_Month_long & " " & show_Year & ".xlsb")
    ThisWorkbook.Sheets("RawData").Copy Before:=Workbooks("RawData - " & show_Month_long & " " & show_Year & ".xlsb").Sheets(1)
    ActiveSheet.Name = format(Range("ReportDate"), "mmm DD")
  
   
 ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1
   
   
   
End If



Application.DisplayAlerts = True
    ActiveWorkbook.Close True
   
          
 MsgBox "Done!"
 
   ThisWorkbook.Save
  
   
Application.ScreenUpdating = True

i click this macro button in a worksheet called "Menu"...i noticed when it crashes and i re-open the file, the "menu" worksheet has been renamed to the reportdate

so im guessing it's crashing here....

Code:
   Set raw = Workbooks.Open(p2 & "\RawData - " & show_Month_long & " " & show_Year & ".xlsb")
    ThisWorkbook.Sheets("RawData").Copy Before:=Workbooks("RawData - " & show_Month_long & " " & show_Year & ".xlsb").Sheets(1)
    ActiveSheet.Name = format(Range("ReportDate"), "mmm DD")


weird thing is it was working fine for months...**** excel
 
Last edited by a moderator:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Crashing in what way?
 
Upvote 0
Remove 'On Error Resume Next'. It's generally bad practice to use this as you will struggle with debugging ... hence you don't know why it's closing!
 
Upvote 0
worked like a charm ! lol ...got rid of that and now works fine ...wtf
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top