Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I create a Show/Hide checkbox

Status
Not open for further replies.

MSIsam

Programmer
Sep 29, 2003
173
US
This should be a simple one. I have created 2 buttons, each with the following macro:
Code:
Sub ShowTab()
    ActiveWindow.DisplayWorkbookTabs = True
End Sub
Code:
Sub HideTab()
    ActiveWindow.DisplayWorkbookTabs = False
End Sub
I would like to change this to a check box for "Show Tabs" so that if unchecked, the tabs are hidden and if checked, the tabs are shown.

I have tried with recording macros but with my limited VB skills, just can't get it done.

Any ideas?
Sam
 
You'll need to use the Control toolbox and place the checkbox in a cell.

Put the following code into the Worksheet_change method

Code:
Sub ShowHideTabs()
  If Worksheetname.checkboxname.value = True Then
         ActiveWindow.DisplayWorkbookTabs = True
  Else
         ActiveWindow.DisplayWorkbookTabs = False
End Sub

Now whenever a value on the checkbox is changed, the sub will kick off and update as requested.

Hope this helps

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top