Not sure how it relates to the problem of writing to the wrong sheet
Even with the 'With Sheet17', without using <dot>Cells to refer to the specific parent object (i.e. Sheet17), just 'Cells' without the dot refers to the ActiveSheet, which may or may not be Sheet17