I’d say you’re missing an “If” statement somewhere, most likely when you’re writing data to sheet “All marks” but it’s hard to say where, without seeing your code. If you’re writing data to the new sheet as a DataTable, add an If statement to check if the RowCount is empty before writing the data.