+ Reply to Thread
Results 1 to 6 of 6

Need help using a toggle button

  1. #1
    Registered User
    Join Date
    01-07-2004
    Location
    Manchester UK
    MS-Off Ver
    Office 2010
    Posts
    73

    Need help using a toggle button

    Hello,

    I am trying to create a spreadsheet in excel 2003, which has a toggle button on it. When I press the button, I want the sheet to display two different sets of data, for example, display data in ColumnA and hide ColumnC and vice versa.

    I am also trying to add protection to the sheet so that when ColumnA is shown, the rest of the sheet is protected, so no data in ColumnC can be deleted accidentally.

    I think it should be really easy, but I cannot get it work.

    Can anyone provide any assistance?

    Thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    Columns("C:C").Select
    Selection.EntireColumn.Hidden = True
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

    HTH
    Google is your best friend!

  3. #3
    Chip Pearson
    Guest

    Re: Need help using a toggle button

    Try something like in the sheet's code module.

    Private Sub ToggleButton1_Click()
    If Me.ToggleButton1.Value = True Then
    Me.Columns("A").Hidden = False
    Me.Columns("C").Hidden = True
    Else
    Me.Columns("A").Hidden = True
    Me.Columns("C").Hidden = False
    End If
    End Sub



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "tanktata"
    <[email protected]> wrote in
    message
    news:[email protected]...
    >
    > Hello,
    >
    > I am trying to create a spreadsheet in excel 2003, which has a
    > toggle
    > button on it. When I press the button, I want the sheet to
    > display two
    > different sets of data, for example, display data in ColumnA
    > and hide
    > ColumnC and vice versa.
    >
    > I am also trying to add protection to the sheet so that when
    > ColumnA is
    > shown, the rest of the sheet is protected, so no data in
    > ColumnC can be
    > deleted accidentally.
    >
    > I think it should be really easy, but I cannot get it work.
    >
    > Can anyone provide any assistance?
    >
    > Thanks in advance.
    >
    >
    > --
    > tanktata
    > ------------------------------------------------------------------------
    > tanktata's Profile:
    > http://www.excelforum.com/member.php...fo&userid=4598
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=556566
    >




  4. #4
    Registered User
    Join Date
    01-07-2004
    Location
    Manchester UK
    MS-Off Ver
    Office 2010
    Posts
    73
    Thanks for the help so far. The code you have given only hides and unhides the data.

    Its the protection of the data that I cant really seem to get working.

  5. #5
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

  6. #6
    Registered User
    Join Date
    01-07-2004
    Location
    Manchester UK
    MS-Off Ver
    Office 2010
    Posts
    73
    I know how to protect a sheet, but I cant get the toggle button to protect/unprotect a worksheet that contains unlocked cells

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1