I am having trouble getting this simple thing to work.

What I need:

A macro that checks cells B9:B350, if the cell is empty then delete comment to the right and if cell contains anything then format comment.

This is what i got so far:

Sub muokkaa()
Dim cell As Range

For Each cell In Range("B9:B350")
        If IsEmpty(cell) Then
            cell.Offset(0, 1).Comment.Delete
            Else
            cell.Offset(0, 1).Comment.Shape.TextFrame.AutoSize = True
        End If
    Next
 
End Sub
I get a object variable or with block variable not set error, what can I do?