Results 1 to 5 of 5

Micrsoft Excel has stopped working

Threaded 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.

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. 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