Code freezes on one computer, not another

MrKowz

Well-known Member
Joined
Jun 30, 2008
Messages
6,653
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hey all,

I've been helping another user on the boards with some code, and something odd is happening. The code runs perfectly fine on my end, but when he runs it (on either of his computers. One is a quad core, the other is less in specs), his Excel freezes if he so much as MOVES the mouse. Both of us are using Excel 2003 (i'm even on a Citrix Thin Client!)

It is a relatively simple VBA procedure that incorporates screenupdating = false, enableevents = false, and manual calculation mode. I even incorporated a statusbar update at every loop, and he says that stops counting altogether.

Here is the code that, as I said, works perfectly fine on my end (I'm even using an identical copy of the worksheet this is meant to be ran on), but causes his computers to freeze.

Code:
Public Sub ReconcileHdrComm2()
Dim s   As Long, _
    d   As Long, _
    sLR As Long, _
    dLR As Long, _
    sWS As Worksheet, _
    dWS As Worksheet
 
Set sWS = Sheets("Source")
Set dWS = Sheets("Sheet1")
 
sLR = sWS.Range("A" & Rows.Count).End(xlUp).Row
dLR = dWS.Range("A" & Rows.Count).End(xlUp).Row
With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
End With
If dLR < sLR Then
    For s = 1 To sLR
        For d = 1 To dLR 'Running this loop is significantly slower, but encompasses the entire sheet
            Application.StatusBar = "Currently checking source row " & s & " versus destination row " & d & "."
            If sWS.Cells(s, 12).Value = dWS.Cells(d, 12).Value And sWS.Cells(s, 9).Value <> dWS.Cells(d, 9).Value Then
                If Left(sWS.Cells(s, 9).Value, InStr(sWS.Cells(s, 9).Value & "-", "-")) = dWS.Cells(d, 9).Value Then
                    dWS.Cells(d, 9).Value = sWS.Cells(s, 9).Value
                    dWS.Cells(d, 9).Interior.ColorIndex = 6
                End If
            End If
        Next d
    Next s
Else
    For d = 1 To dLR
        For s = 1 To sLR 'Running this loop is significantly slower, but encompasses the entire sheet
            Application.StatusBar = "Currently checking source row " & s & " versus destination row " & d & "."
            If sWS.Cells(s, 12).Value = dWS.Cells(d, 12).Value And sWS.Cells(s, 9).Value <> dWS.Cells(d, 9).Value Then
                If Left(sWS.Cells(s, 9).Value, InStr(sWS.Cells(s, 9).Value & "-", "-")) = dWS.Cells(d, 9).Value Then
                    dWS.Cells(d, 9).Value = sWS.Cells(s, 9).Value
                    dWS.Cells(d, 9).Interior.ColorIndex = 6
                End If
            End If
        Next s
    Next d
End If
With Application
    .ScreenUpdating = True
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .StatusBar = False
End With
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Update - actually just found out he is using Excel 2007
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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