+ Reply to Thread
Results 1 to 2 of 2

Hide/unhide Cell contents based on checkbox

  1. #1
    Registered User
    Join Date
    04-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Hide/unhide Cell contents based on checkbox

    I have searched with no luck. I am trying to hide the content of Cells A21 and B21 when the checkbox in D21 is unchecked and then unhide the same two cells when the same check box is checked. The best I have come up with is formatting the cells to ";;;" to hide them, but I can not for the life of me make it remove the ";;;" and unhide them. Is there a better way?

    Sub Hide()

    If ThisWorkbook.Worksheets(1).Shapes("Check Box 19").OLEFormat.Object.Value = 1 Then
    Range("A21:B21").Select
    Selection.NumberFormat = ";;;"

    ElseIf ThisWorkbook.Worksheets(1).Shapes("Check Box 19").OLEFormat.Object.Value = 0 Then
    Range("A21:B21").Select
    Selection.NumberFormat = ""

    End If
    End Sub
    That is the best I have made so far
    Last edited by Kelton; 04-25-2014 at 05:33 PM.

  2. #2
    Registered User
    Join Date
    04-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Hide/unhide Cell contents based on checkbox

    Nevermind, went a totally different direction and ended up figuring it out. I was making it stupid harder than it needed to be.

    Ended up using strike out with this code:

    Sub Hide16()

    If ThisWorkbook.Worksheets(1).Shapes("Check Box 17").OLEFormat.Object.Value = 1 Then
    Range("A36:B36").Select
    Selection.Font.Strikethrough = False

    Else
    Range("A36:B36").Select
    Selection.Font.Strikethrough = True

    End If
    End Sub




    But Found out all I had to do is make it a straight Else statement instead of trying to over complicate it. My newness to coding is showing, don't look! Here is the code for it for anyone in the future!

    Sub Hide()

    If ThisWorkbook.Worksheets(1).Shapes("Check Box 19").OLEFormat.Object.Value = 1 Then
    Range("A21:B21").Select
    Selection.NumberFormat = ";;;"

    Else
    Range("A21:B21").Select
    Selection.NumberFormat = ""

    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How do I hide and unhide cell contents?
    By cdmterence in forum Excel General
    Replies: 8
    Last Post: 01-02-2014, 03:55 AM
  2. [SOLVED] Checkbox VBA - Hide/Unhide Rows and/or Columns based on cell values
    By gravy258 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-21-2013, 05:39 PM
  3. Hide/Unhide Checkbox using another checkbox
    By drunken_master in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-14-2008, 12:37 PM
  4. Checkbox to hide & unhide worksheet
    By grantj in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-18-2008, 01:13 PM
  5. [SOLVED] Hide & Unhide with a Checkbox
    By Jonathan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-05-2005, 08:05 AM

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