Results 1 to 3 of 3

Excel file hangs when code for checking data added

Threaded View

  1. #1
    Registered User
    Join Date
    10-12-2011
    Location
    Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    94

    Excel file hangs when code for checking data added

    Hi Expert,

    Please help to see below code. My Excel file hangs when code added for checking whether data exist at sheet "Registration List 2018". MsgBox dialog box keep on running. If I remove this line of code

    (If Application.WorksheetFunction.CountIf(Sheets("Search").Range("B:B"), Target.Value) + Application.WorksheetFunction.CountIf(Sheets("Registration List 2018").Range("A:A"), Target.Value) = 0 Then
     MsgBox "No record found, please contact HR Personnel"
        Target.ClearContents
        Else
     'Nothing)
    the system work fine.

    Private Sub Worksheet_Change(ByVal Target As Range)
       
     If Target.Address = "$B$5" Then
     If Application.WorksheetFunction.CountIf(Sheets("Search").Range("B:B"), Target.Value) + Application.WorksheetFunction.CountIf(Sheets("Registration List 2018").Range("A:A"), Target.Value) = 0 Then
     MsgBox "No record found, please contact HR Personnel"
        Target.ClearContents
        Else
     'Nothing
     
     If Application.WorksheetFunction.CountIf(Sheets("Search").Range("B:B"), Target.Value) + Application.WorksheetFunction.CountIf(Sheets("Reported").Range("A:A"), Target.Value) > 1 Then
     MsgBox "You have entered a duplicate number, please try again"
        Target.ClearContents
        Else
     'Nothing
     
     If Len(Target.Value) = 12 Then
          Call Copydata
        End If
    End If
    End If
    End If
    
    End Sub
    Last edited by AliGW; 07-18-2018 at 05:56 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel 2016 file hangs on open
    By jonathanwsmith in forum Excel General
    Replies: 4
    Last Post: 04-23-2018, 12:52 PM
  2. excel hangs after giving File Open
    By Harpinator in forum Excel General
    Replies: 1
    Last Post: 04-20-2006, 12:40 PM
  3. [SOLVED] Excel hangs on opening file
    By Dee in forum Excel General
    Replies: 0
    Last Post: 02-15-2006, 12:20 PM
  4. [SOLVED] Excel 2003, XP hangs opening file on SSL
    By BN in forum Excel General
    Replies: 0
    Last Post: 01-31-2006, 03:35 AM
  5. Excel file hangs for several min, before opening
    By bill in forum Excel General
    Replies: 1
    Last Post: 08-31-2005, 03:05 PM
  6. [SOLVED] a certain excel file hangs up when i open it
    By dwightf1_ph in forum Excel General
    Replies: 1
    Last Post: 03-09-2005, 08:59 AM
  7. Code hangs Excel ... Why? ... and how can i debug??
    By Simon May in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2005, 03:06 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