Toggle Button

W

William

I have a toggle button that I would like to unhide some columns and remove a
border line on the first click. On the second click, I would like for it to
rehide the same columns and put the line back. I thought that I had this
figured out. Please help. This is what I have so far:

Private Sub ToggleButton1_Click()
ActiveSheet.Range(“C:Eâ€).EntireColumn.Hidden=False
ActiveSheet.Range("F:F").Borders(xlEdgeLeft).LineStyle = xlNone
Not.ActiveSheet.Range“C:Eâ€).EntireColumn.Hidden=True
Not.ActiveSheet.Range("F:F").Borders(xlEdgeLeft).Weight = xlThin
End Sub
 
J

Jim Cone

Private Sub ToggleButton1_Click()
If ToggleButton1.Value = False Then
Me.Range("C:E").EntireColumn.Hidden = False
Me.Range("F:F").Borders(xlEdgeLeft).LineStyle = xlNone
Else
Me.Range("C:E").EntireColumn.Hidden = True
Me.Range("F:F").Borders(xlEdgeLeft).Weight = xlThin
End If
End Sub
--
Jim Cone
Portland, Oregon USA



"William"
wrote in message
I have a toggle button that I would like to unhide some columns and remove
a border line on the first click. On the second click, I would like for it to
rehide the same columns and put the line back. I thought that I had this
figured out. Please help. This is what I have so far:

Private Sub ToggleButton1_Click()
ActiveSheet.Range(“C:Eâ€).EntireColumn.Hidden=False
ActiveSheet.Range("F:F").Borders(xlEdgeLeft).LineStyle = xlNone
Not.ActiveSheet.Range“C:Eâ€).EntireColumn.Hidden=True
Not.ActiveSheet.Range("F:F").Borders(xlEdgeLeft).Weight = xlThin
End Sub
 
R

Rick Rothstein

Try it something like this...

Private Sub ToggleButton1_Click()
With ActiveSheet
If ToggleButton1.Value Then
.Columns("C:E").EntireColumn.Hidden = True
.Columns("F:F").Borders(xlEdgeLeft).Weight = xlThin
Else
.Columns("C:E").Hidden = False
.Columns("F:F").Borders(xlEdgeLeft).LineStyle = xlNone
End If
End With
End Sub

Although it is possible that I have the Then and Else block statements
reversed in location.
 

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