VBA - Hide specific cell comments

bernie69

New Member
Joined
Feb 18, 2011
Messages
4
I would like to write cell comments in a worksheet that I have created that are meant for the administrator only. There are some comments in other cells that are meant for users.

Is there are way using VBA I can
a) assess the comments in a cell (e.g. the text starts with 'Admin:'). What property is this?
b) hide those comments so the user cannot view them

I have tried using the visible property but this doesn't do all I need it to. I do have a fallback option of using textboxes but this could end up looking a bit messy if there's lots of them!

Any help would be much appreciated.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
This is a bit rough and ready (and untested) but it should get you started.
Code:
Sub test()
    Dim comm As Comment, ws As Worksheet
    For Each ws In Worksheets
        For Each comm In ws.Comments
            If Left(comm.Text, 5) = "Admin" Then
                comm.Visible = False
            End If
        Next
    Next
End Sub
 
Upvote 0
Thanks for this, is there any way of entirely hiding the comments box though? i.e. so the user can't hover over the cell and display the comment?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,848
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top