Macro for hiding and unhiding Comments.

Newbienew

Active Member
Joined
Mar 17, 2017
Messages
395
Office Version
  1. 2016
Platform
  1. Windows
I am looking to a macro that will allow me to use the transaction code to hide and unhide cell comments. I have the comments displayed but want to make a button that will hide them, much like a help button. In addition, I also need to make the same macro with the same purpose but able to work with a unlock and lock aspect to the button.

Follow up question, do macro coding make an excel workbook larger in size?

Thank you for your help in advance
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Re: Marco for hiding and unhiding Comments.

They do increase size, but not noticeably.

Here's how to turn comments on/off (unhide/hide)

Code:
Sub showcomments()


'turn on
       Application.DisplayCommentIndicator = xlCommentAndIndicator
       
'turn off
       Application.DisplayCommentIndicator = xlNoIndicator


End Sub

Not following the lock/unlock aspect.
 
Last edited:
Upvote 0
Re: Marco for hiding and unhiding Comments.

I attempted you use the code but the comments disappear but never return. I am very horrible and doing these things on the first try. I did a circle shape for my button and added it as a macro.
 
Upvote 0
Re: Marco for hiding and unhiding Comments.

Well the macro as is shows then hides them, so it worked (they're still there by the way, the markers are also removed so they look gone).

Maybe try 2 macros, 1 to hide, 1 to unhide.

Code:
Sub hidecomments()

       Application.DisplayCommentIndicator = xlNoIndicator

[FONT=Verdana]End Sub[/FONT]

Code:
Sub showcomments()

       Application.DisplayCommentIndicator = xlCommentAndIndicator
       
E[FONT=Verdana]nd Sub[/FONT]
 
Last edited:
Upvote 0
Re: Marco for hiding and unhiding Comments.

Separately it works great I will use this method in the nearing future. If its possible to make it toggle between the two with one image or shape. As a help button?
 
Upvote 0
Re: Marco for hiding and unhiding Comments.

If its possible to make it toggle between the two with one image or shape. As a help button?
Try assigning this macro to your image or shape...
Code:
Sub ToggleComments()
  If Application.DisplayCommentIndicator = xlCommentAndIndicator Then
    Application.DisplayCommentIndicator = xlNoIndicator
  Else
    Application.DisplayCommentIndicator = xlCommentAndIndicator
  End If
End Sub
 
Upvote 0
Re: Marco for hiding and unhiding Comments.

@mrshl9898 Thank you for your help. I will be using your code on another project I have, Thank you so much for the code
@Rick Rothstein Thank you so much for your assistance. This code works great for the project I am working on. Thank you greatly
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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