It counts cells containing anything; if there are none, it deletes the sheet.

In your code,

IsEmpty(Range("C9")) ...
Range refers to the active worksheet, not the worksheet of the loop variable, which would be

IsEmpty(ws.Range("C9")) ...