View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Hudson Ken Hudson is offline
external usenet poster
 
Posts: 186
Default Macro Halting During Execution

As part of a large macro I have the code shown below. I have distributed the
macro to scores of users. For some of them the macro halts execution at the
last line of code shown below. They can click on the run sub/user form button
in the VB editor and the macro will then run to conclusion. Any ideas as to
why it would break for some folks at that line of code? I'm baffled.

For ILoop = 1 To ShCount
Sheets(ILoop).Activate
UndCount = 0
Rows(1).Delete
NumRows = Cells(Rows.Count, "C").End(xlUp).Row
'Get samples for UO and AP.
If (Left(ActiveSheet.Name, 3)) = "UND" Then
For Iloop2 = 1 To NumRows
If Application.CountA(Range("G" & Iloop2 & ":I" & Iloop2)) 0
Then
UndCount = UndCount + 1
Cells(Iloop2, "J") = UndCount
UndTtl = UndTtl + Cells(Iloop2, "G") + Cells(Iloop2, "H") +
Cells(Iloop2, "I")
End If
Next Iloop2
If UndCount < 16 Then
For Iloop2 = 1 To NumRows
If Not IsEmpty(Cells(Iloop2, "J")) Then
Cells(Iloop2, "J") = "X"
End If
Next Iloop2
Else
Num = 15
t = UndCount
GenNUniqueRandom
For Iloop2 = 1 To Num
For Iloop3 = 1 To NumRows
If Cells(Iloop3, "J") = RndNo(Iloop2) Then
Cells(Iloop3, "J") = "X"
Exit For
End If
Next Iloop3
Next Iloop2
End If
Cells(NumRows + 2, "A") = "Total count of records 90 days old"
Cells(NumRows + 2, "D") = UndCount
Cells(NumRows + 3, "A") = "Total dollar value of records 90 days
old"
Cells(NumRows + 3, "D") = UndTtl
UndCount = 0
UndTtl = 0
Else
'Get samples for non-MCCF AR.
For Iloop2 = 1 To NumRows
If Application.CountA(Range("G" & Iloop2 & ":I" & Iloop2)) 0
And _
Not IsEmpty(Cells(Iloop2, "B")) And _
IsNumeric(Mid(Cells(Iloop2, "C"), 8, 1)) Then
ARCount = ARCount + 1
ARTtl = ARTtl + Cells(Iloop2, "G") + Cells(Iloop2, "H") +
Cells(Iloop2, "I")
Cells(Iloop2, "J") = ARCount
End If
Next Iloop2
If ARCount < 11 Then
--
Ken Hudson