Yes, my fault. Move the End If up a row, before the line that says r = r + 1.

Sorry.

Regards, TMS