Hi Everyone,
Sorry for the poor grammar in the title. Okay here's the issue I'm running into. I have some code I'm writing to compare two different payment spreadsheets. At this point I'm just trying to collect the number of different payment types associated with each person. My problem is that, when I run the code normally, it skips over roughly 100 records before collecting any information. When I insert a breakpoint within my loop and step through each time everything works just fine. I can't figure out what I need to add or clean up in my loop to get the performance I do when I step through it. The code for my loop is shown below.
Code:
Dim lNameCol As Excel.Range, C As Excel.Range, sLastRow As Integer, i As Integer, numPay As Integer
sLastRow = xlWs1.Range("A1").End(xlDown).Row
i = 2
'Set C = xlWs1.Range("E6:K6")
'numPay = xl.WorksheetFunction.CountIf(C, ">" & 0)
Do Until i > sLastRow
Set C = xlWs1.Range("E" & i & ":" & "K" & i)
numPay = xl.WorksheetFunction.CountIf(C, ">" & 0)
If numPay > 0 Then
Debug.Print xlWs1.Range("A" & i) & ", " & xlWs1.Range("B" & i)
End If
i = i + 1
Loop
Those two lines are commented out were my initial test of the logical comparison. I usually set the breakpoint at the incremental increase for variable i. If anyone can see some problem with the code here I would love some hints at what I can do to improve performance.
Thanks!
Ryan