Where exactly did you put that code?

Did you definitely include the worksheet reference, ws?