Hi,
I have worksheet2 filtered down, and I copied the filtered data over to worksheet1. Below is the loop for counting the number of days from the date in column D, and placing the number in column E. It is functioning correctly, but it continues to try and count past the data set in column D. It is actually taking the total number of rows from worksheet2 before it was filtered, and that is how far the loop is executing in column E.
Please assist me with the following question:
How do I make the loop stop at the end of column D in worksheet1?
'Count Days Since Last Call
Dim rIndex As Long
With Worksheets("Worksheet1")
rIndex = 3
Do While rIndex <= Cells(Rows.Count, "D").End(xlUp).Row
If .Cells(rIndex, "D") = "N/A" Then
.Cells(rIndex, "E").Value = "N/A"
Else
.Cells(rIndex, "E").Value = Date - .Cells(rIndex, "D")
End If
rIndex = rIndex + 1
Loop
End With
Thank you,
Nick
Bookmarks