+ Reply to Thread
Results 1 to 5 of 5

Micrsoft Excel has stopped working

Hybrid View

Elikki Micrsoft Excel has stopped... 11-11-2014, 01:17 PM
xladept Re: Micrsoft Excel has... 11-11-2014, 08:16 PM
FDibbins Re: Micrsoft Excel has... 11-11-2014, 08:20 PM
Elikki Re: Micrsoft Excel has... 11-12-2014, 04:47 PM
Elikki Re: Micrsoft Excel has... 11-12-2014, 04:46 PM
  1. #1
    Registered User
    Join Date
    11-11-2014
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    3

    Micrsoft Excel has stopped working

    Hi,
    I am new and this is my first post.
    I wrote a VBA code using excel 2010 and every time I run it, I get this error, "Microsoft Excel Has Stopped working". The thing is if I run it from the module, it works fine, but if I click on the button to which a macro is assigned the error popes up. The code is as follows.


    Sub CustContact()
     Call FileOpenContact
    End Sub
    
    Sub FileOpenContact()
    
    Dim Path            As String
    Dim FileName        As String
    Dim Wkb             As Workbook
    Dim ws              As Worksheet
    Dim FolderName      As Variant
    Dim Dates           As String
    
    
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Path = "C:\?????\Desktop\?????" 'Change as needed
        FileName = Dir(Path & "\?????????????????.xlsx", vbNormal)
        On Error Resume Next
        Do Until FileName = ""
            Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
            For Each ws In Wkb.Worksheets
                ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
            Next ws
            Wkb.Close False
            FileName = Dir()
        On Error Resume Next
        Loop
          Call SelcectCode
    End Sub
    
    Sub SelcectCode()
    
    Dim x As Integer, code As String
    
        Sheets("Codes").Activate
        
        lr = Range("A" & Rows.Count).End(xlUp).Row
    
            For x = 1 To lr
                If Range("B1").Value = 1 Then
                ElseIf Range("B1").Value = x Then
                    code = Cells(x, 1)
                    Exit For
                End If
            Next x
            FindContact code
    End Sub
    
    Sub FindContact(ByRef code)
    
    Dim x As Integer
    
        Sheets("Customer").Activate
         ActiveSheet.Name = code
        
        lr = Range("A" & Rows.Count).End(xlUp).Row
    
            For x = lr To 2 Step -1
                If Cells(x, 3) = code Then
                Else
                    Cells(x, 1).EntireRow.Delete
                End If
            Next x
            Columns("B").Delete
            Columns("C:H").Delete
            Columns("Q").Delete
            Columns("R:T").Delete
    End Sub
    Thanks in advance!
    Last edited by FDibbins; 11-11-2014 at 08:19 PM.

  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: Micrsoft Excel has stopped working

    Hi Elikki,

    Welcome to the Forum!

    I have repaired my 2010 twice since I got it - have you tried repairing your Office 2010?

    When we post code we put code tags around it - you need only to highlight your code and click on the #
    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
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Micrsoft Excel has stopped working

    Elikki, welcome to the forum

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I have added them for you - this time
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    11-11-2014
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    3

    Re: Micrsoft Excel has stopped working

    Thanks! I just posted the code again using the code wrap

  5. #5
    Registered User
    Join Date
    11-11-2014
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    3

    Re: Micrsoft Excel has stopped working

    Sub CustContact()
     Call FileOpenContact
    End Sub
    
    Sub FileOpenContact()
    
    Dim Path            As String
    Dim FileName        As String
    Dim Wkb             As Workbook
    Dim ws              As Worksheet
    Dim FolderName      As Variant
    Dim Dates           As String
    
    
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Path = "C:\?????\Desktop\?????" 'Change as needed
        FileName = Dir(Path & "\?????????????????.xlsx", vbNormal)
        On Error Resume Next
        Do Until FileName = ""
            Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
            For Each ws In Wkb.Worksheets
                ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
            Next ws
            Wkb.Close False
            FileName = Dir()
        On Error Resume Next
        Loop
          Call SelcectCode
    End Sub
    
    Sub SelcectCode()
    
    Dim x As Integer, code As String
    
        Sheets("Codes").Activate
        
        lr = Range("A" & Rows.Count).End(xlUp).Row
    
            For x = 1 To lr
                If Range("B1").Value = 1 Then
                ElseIf Range("B1").Value = x Then
                    code = Cells(x, 1)
                    Exit For
                End If
            Next x
            FindContact code
    End Sub
    
    Sub FindContact(ByRef code)
    
    Dim x As Integer
    
        Sheets("Customer").Activate
         ActiveSheet.Name = code
        
        lr = Range("A" & Rows.Count).End(xlUp).Row
    
            For x = lr To 2 Step -1
                If Cells(x, 3) = code Then
                Else
                    Cells(x, 1).EntireRow.Delete
                End If
            Next x
            Columns("B").Delete
            Columns("C:H").Delete
            Columns("Q").Delete
            Columns("R:T").Delete
    End Sub

+ 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. Excel has stopped working
    By micklloyd in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2014, 09:47 AM
  2. Excel Stopped Working
    By drozen in forum Excel General
    Replies: 2
    Last Post: 09-11-2014, 08:05 AM
  3. Excel has stopped working?
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2010, 03:00 AM
  4. why formulas have stopped working in Excel?
    By queenjude in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] excel 97 stopped working
    By john f in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-13-2005, 07:06 PM

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