P is inside the quotes, so it is just "p".You need it outside the quotesActiveCell.Rows("1:" & p).EntireRow.Select