Excel 2013 crashes when running macro.

vimal_

New Member
Joined
Apr 23, 2015
Messages
7
Hi,

Excel 2013 crashes when running macro. same macro is working fine in excel 2010/2007. there is no addi-in are enabled in excdel. also it does not crash when step-in through lines.

Kindly help!!.. it's making impossible even testing macro.

Vimal
 
Code here!.. its works fine in excel 2007/2010.

Code:
Sub Prepare_Modules()    Dim FSO As Scripting.FileSystemObject
    Dim FF As Scripting.Folder
    Dim ss As String
    
    Set FSO = New Scripting.FileSystemObject
    ss = GetFolder(msoFileDialogFolderPicker)
    If Not ss = "" Then
        Set FF = FSO.GetFolder(ss)
        
        Application.ScreenUpdating = False
        DoOneFolder FF
        Application.ScreenUpdating = True
        
        MsgBox "Completed"
    Else
        MsgBox "No Folder Selected"
    End If
End Sub
Sub DoOneFolder(FF As Scripting.Folder)
    Dim F As Scripting.File
    Dim SubF As Scripting.Folder
    Dim WB As Workbook
    Dim r, c, i, x, n As Long
    Dim BM, PR, CR, AR, AED As Range
    
    For Each F In FF.Files
        If InStr(F.Type, "Excel") > 0 Then
            If InStr(F.Name, "Module") > 0 Then
            Workbooks.Open F.Path
            Set WB = ActiveWorkbook
            wbName = ActiveWorkbook.Name
            Sheets("Expense Data").Select
            r = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
            c = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
            
            For i = 7 To c
            If Not Cells(r, i) = 0 Then
                For x = 7 To r - 1
                    If Not Cells(x, i) = 0 Then
                    Set BM = ActiveSheet.Range("B2")
                    Set PR = ActiveSheet.Range("B" & x & ":" & "F" & x)
                    Set CR = ActiveSheet.Cells(6, i)
                    Set NR = ActiveSheet.Cells(5, i)
                    Set AR = ActiveSheet.Cells(x, i)
                    Set AED = Sheets("Cost Center Breakup").Range("D2")
                    
                    Windows(ThisWorkbook.Name).Activate
                    Sheets("Modules").Select
                    n = Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row
                    Range("A" & n) = FF.Name
                    Range("B" & n) = BM.Value
                    Range("H" & n) = CR.Value
                    Range("I" & n) = NR.Value
                    Range("J" & n) = AR.Value
                    Range("K" & n) = AED.Value
                    PR.Copy
                    Range("C" & n).PasteSpecial xlPasteValues
                    Application.CutCopyMode = False
                    
                    Windows(wbName).Activate
                    Set BM = Nothing
                    Set PR = Nothing
                    Set CR = Nothing
                    Set NR = Nothing
                    Set AR = Nothing
                    Set AED = Nothing
                    End If
                Next
            End If
            Next
            
            Windows(wbName).Activate
            WB.Close False
            End If
        End If
    Next F
    
    For Each SubF In FF.SubFolders
        DoOneFolder SubF
    Next SubF
End Sub


Function GetFolder(strPath As String) As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
    .Title = "Select Month Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
Set fldr = Nothing
End Function
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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