Sub AssignNum()
Dim iTotalCol As Integer
Dim iNBRFirstRow As Integer
Dim iLastRow As Integer
Dim iHRISCol As Integer
Dim strColLetter As String
Dim iCount As Integer
Dim iNum As Integer
iNum = 1
With shtReport
iHRISCol = .Range("rngHRISID").Column
iTotalCol = .Range("rngStart").Column
iNBRFirstRow = .Range("rngHRISID").Row + 1
iLastRow = .Cells(.Rows.Count, iHRISCol).End(xlUp).Row
.Range("A" & iNBRFirstRow & ":A" & iLastRow).ClearContents
'Assign Num number if total > 0 and Parent HRIS ID equals HRIS ID
For iCount = iNBRFirstRow To iLastRow
If .Cells(iCount, iTotalCol).Value > 0 And _
.Cells(iCount, iHRISCol) = .Cells(iCount, iHRISCol - 1) Then
.Range("A" & iCount).Value = iNum
iNum = iNum + 1
End If
Next iCount
End With
End Sub
Here, the value of iLastRow is 761 and iNBRFirstRow is 7. So, iCount should loop through 7 to 761, but it stops at 184, terminating the for loop too early. I just can't figure out what's causing this issue. Could anyone help?
.Cells(iCount, iTotalCol).Value>0 after row 184? (or.Cells(iCount, iHRISCol) = .Cells(iCount, iHRISCol - 1)iCount = 183, and selectBreak When Value Is True. Run the code and it should stop at iteration 183. Now step through theIfstatements withF8, confirm that bothIfconditions are met. The next iteration will be 184 - are bothIfconditions met?