For j = 5 To Range("A" & Rows.Count).End(xlUp).Row
The code goes down to the last non-empty value in column A, so it does not stop if there is empty between 2 rows.