Originally Posted by
lior03
hello
i am trying to disable comments altogether.
namely prevent the user from entering comments in a
workbook.
Sub nocomments()
Dim ws As Worksheet
Dim cell As Range
For Each ws In ActiveWorkbook.Worksheets
cell.Comment.Visible = False
MsgBox "no comments"
Next
End Sub
please help.
thanks
this is a bit of brute force, but it works. It uses the worksheet selection change procedure to sweep the range of cells with any comments and clear any comments.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xlLastCol As Long
Dim xlLastRow As Long
On Error GoTo EndSub
With ActiveSheet
xlLastCol = .Cells.Find("*", .Cells(1), xlComments, _
xlWhole, xlByColumns, xlPrevious).Column
xlLastRow = .Cells.Find("*", .Cells(1), xlComments, _
xlWhole, xlByRows, xlPrevious).Row
End With
Range(Cells(1, 1), Cells(xlLastRow, xlLastCol)).ClearComments
EndSub:
End Sub