Declare this variable

Code:
set wksFormat = Worksheets("YourSheetName")
just above the
Code:
With wksFormat
line.

obviously replace the "yoursheetname" with actual sheet name