Jason Sawyer
New Member
- Joined
- May 20, 2009
- Messages
- 3
Learning on my own, forgive stupidity please.
I have a spreadsheet with 100 toggle buttons that when true/false will show/hide the comments of a cell.
Private Sub ToggleButton1_Click()
Range(ToggleButton1.LinkedCell).Select
If ToggleButton1.Value = True Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = True
ElseIf ToggleButton1.Value = False Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = False
End If
End Sub
This works great. I would like to have the commands generic so that I can point all of the buttons to point to a ?macro? so I do not have to rename each ToggleButton#.
Private Sub ToggleButton1_Click()
Module1.ToggleCommand
End Sub
Private Sub ToggleButton2_Click()
Module1.ToggleCommand
End Sub
Sub ToggleCommand()
Range(ToggleButton.LinkedCell).Select
If ToggleButton.Value = True Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = True
ElseIf ToggleButton.Value = False Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = False
End If
End Sub
But this does not work. Am I just an idiot or can something like this be accomplished, or both? What I have so far, is pieced together from what I figured out playing with VBA and searching the web.
Thanks,
Jason
I have a spreadsheet with 100 toggle buttons that when true/false will show/hide the comments of a cell.
Private Sub ToggleButton1_Click()
Range(ToggleButton1.LinkedCell).Select
If ToggleButton1.Value = True Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = True
ElseIf ToggleButton1.Value = False Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = False
End If
End Sub
This works great. I would like to have the commands generic so that I can point all of the buttons to point to a ?macro? so I do not have to rename each ToggleButton#.
Private Sub ToggleButton1_Click()
Module1.ToggleCommand
End Sub
Private Sub ToggleButton2_Click()
Module1.ToggleCommand
End Sub
Sub ToggleCommand()
Range(ToggleButton.LinkedCell).Select
If ToggleButton.Value = True Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = True
ElseIf ToggleButton.Value = False Then
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.Comment.Visible = False
End If
End Sub
But this does not work. Am I just an idiot or can something like this be accomplished, or both? What I have so far, is pieced together from what I figured out playing with VBA and searching the web.
Thanks,
Jason