Hi, everybody
I have a macro which works perfectly:
This code makes my button act like a toggle button.
To make the macro work, we select a range of Comments on the worksheet.
Then we click on the button: It creates a shape, and the texts of the comments are listed in the shape.
If we click on the button again, the shape is deleted.
Here is the code for Sub ClearShape1
The code for Sub CreateShape1_ListCommentsTextInShape1 is more complicated.
The macro works perfectly.
There is only 1 small problem.
If we want to Create or Clear the shape, we must sometimes click twice (instead of once) on the Toggle Button.
This depends on the value Flag1 happens to have at that moment.
-----------
To avoid the problem, I want to stop using Flag1.
I want a macro which first checks if the Shape1 is displayed:
If No, it calls Sub CreateShape1_ListCommentsTextInShape1
If Yes, it calls Sub ClearShape1
How to do that?
I tried the following, but doesn't work:
I am not sure "Visible" is the correct property to use.
I also tried = Nothing.
Can anybody help?
Thanks
Leon
I have a macro which works perfectly:
Code:
Sub Toggle_ListSelectedCmts()
Static Flag1 As Boolean
If Flag1 = True Then
Call CreateShape1_ListCommentsTextInShape1
Flag1 = False
ElseIf Flag1 = False Then
Call ClearShape1
Flag1 = True
End If
This code makes my button act like a toggle button.
To make the macro work, we select a range of Comments on the worksheet.
Then we click on the button: It creates a shape, and the texts of the comments are listed in the shape.
If we click on the button again, the shape is deleted.
Here is the code for Sub ClearShape1
Code:
Sub ClearShape1()
On Error Resume Next
ActiveSheet.Shapes("Shape1").Delete
End Sub
The code for Sub CreateShape1_ListCommentsTextInShape1 is more complicated.
The macro works perfectly.
There is only 1 small problem.
If we want to Create or Clear the shape, we must sometimes click twice (instead of once) on the Toggle Button.
This depends on the value Flag1 happens to have at that moment.
-----------
To avoid the problem, I want to stop using Flag1.
I want a macro which first checks if the Shape1 is displayed:
If No, it calls Sub CreateShape1_ListCommentsTextInShape1
If Yes, it calls Sub ClearShape1
How to do that?
I tried the following, but doesn't work:
Code:
Sub Toggle_ListSelectedCmts()
If ActiveSheet.Shapes("Shape1").Visible = False Then Call [I]CreateShape1_ListCommentsTextInShape1[/I]
If ActiveSheet.Shapes("Shape1").Visible = True Then Call [I]ClearShape1[/I]
End Sub
I am not sure "Visible" is the correct property to use.
I also tried = Nothing.
Can anybody help?
Thanks
Leon
Last edited: