As to the error, this line
is giving the error because rngLoop.Value equals "". A sheet must have a name. This statement
Set rng = .Range("B2", "B" & .Cells(Rows.Count, "B").End(xlUp).Row)
is returning 19 cells (screenshot
https://imgur.com/E9O0J4R) because of the If statement in the formula. You can add
If rngLoop.Value = "" Then Exit For
under the For each line to stop looping when you encounter this.