Hide all open comments in a particular range

T

tx12345

Hi

I have a range of cells on a sheet that have comments the user can make
visible. I know how to hide one cells comments:


Code:
--------------------
Range("a1").Select
ActiveCell.Comment.Visible = False
--------------------


vut what if there are several comments open in range("a1:a30")? Is
there a way to close them all at one time *without* employing the
universal command to hide all comments throughout the workbook?

Many thanks

tx
 
G

Guest

Some vba like the following should toggle the visibility of the comments in
the current selection:

Sub clrComment()
Dim rng As Range
For Each rng In Selection
If Not rng.Comment Is Nothing Then
rng.Comment.Visible = Not rng.Comment.Visible
End If
Next rng
End Sub

Hope that helps,

TK
 
T

tx12345

That is a nice little piece of code, thanks.

But I can't figure out how to make it only toggle off. is there a way
to customize the code so it only closes the comments and not opens
them?

thanks again

tx
 
G

Guest

If you only want to make the comments invisible change the code from

rng.Comment.Visible = Not rng.Comment.Visible
to
rng.Comment.Visible = False

TK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top