This code is meant to copy and paste x number of times based on a cell value.
It bugs out and doesn't stop the loop.
When I step into it, it runs once and stops.
"O7" is how many times I would like to copy and paste.
Sub WorksheetLoop()
Dim NS As Integer
NS = Sheets("Dashboard").Range("O7").Value
i = 1
Do
Sheets("Dashboard").Select
Sheets("Dashboard").Range("A9").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Archive").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
i = i + 1
Loop Until i = NS
MsgBox "loop Complete"
End Sub