+ Reply to Thread
Results 1 to 5 of 5

Checkbox hide if cell is blank

Hybrid View

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,977

    Re: Checkbox hide if cell is blank

    "when a cell is blank I want the active x check box not to be visible but when the cell is populated by a formula I want the check box to be visible."

    If there is a formula in a cell, and the result is blank, the cell is still being populated by the formula, so your description is a little ambiguous.

    Do you mean: There is a formula in the cell. When the result of the formula is the null string, I want the checkbox to be invisible. When the formula produces a non-null result, I want the checkbox to be visible.

    If that's what you mean then set your checkboxes up to be named CheckBox1, CheckBox2, etc.
    Private Sub Worksheet_Calculate()
    
       Dim C As Range
       Dim CBNum As Long
    
       For Each C In Range("B25:B39")
          CBNum = CBNum + 1
          Me.Shapes("CheckBox" & CBNum).Visible = (C.Value <> "")
       Next C
        
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Checkbox hide if cell is blank

    Quote Originally Posted by 6StringJazzer View Post
    "when a cell is blank I want the active x check box not to be visible but when the cell is populated by a formula I want the check box to be visible."

    If there is a formula in a cell, and the result is blank, the cell is still being populated by the formula, so your description is a little ambiguous.

    Do you mean: There is a formula in the cell. When the result of the formula is the null string, I want the checkbox to be invisible. When the formula produces a non-null result, I want the checkbox to be visible.

    If that's what you mean then set your checkboxes up to be named CheckBox1, CheckBox2, etc.
    Private Sub Worksheet_Calculate()
    
       Dim C As Range
       Dim CBNum As Long
    
       For Each C In Range("B25:B39")
          CBNum = CBNum + 1
          Me.Shapes("CheckBox" & CBNum).Visible = (C.Value <> "")
       Next C
        
    End Sub
    Appologies yes thats what I mean

    The formula I have is
    Formula: copy to clipboard
    =IF($B$9='Reference Sheet'!$B$1,'Reference Sheet'!B2,IF($B$9='Reference Sheet'!$C$1,'Reference Sheet'!C2,IF($B$9='Reference Sheet'!$D$1,'Reference Sheet'!D2,IF($B$9='Reference Sheet'!$E$1,'Reference Sheet'!E2,IF($B$9='Reference Sheet'!$F$1,'Reference Sheet'!F2,IF($B$9='Reference Sheet'!$G$1,'Reference Sheet'!G2,IF($B$9='Reference Sheet'!$H$1,'Reference Sheet'!H2,"")))))))


    So I want the checkbox hidden if the formula result returns ""

    I have tried the code you kindly provided for me but I cant seem to get the desired result, maybe i'm being silly.

    I Have attached the workbook

    I get the following error as per screenshots.

    Macro Error.jpg

    Macro Error1.jpg
    Attached Files Attached Files

+ 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] Macro Checkbox to hide multiple blank rows
    By qiyusi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-22-2014, 11:45 PM
  2. Replies: 2
    Last Post: 04-26-2014, 07:34 PM
  3. [SOLVED] Hide/unhide Cell contents based on checkbox
    By Kelton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2014, 04:25 PM
  4. Hide Column If Cell Value is empty from Checkbox
    By Guple in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2014, 04:40 AM
  5. IF date in cell is not a workday then hide checkbox
    By renden in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2012, 09:48 AM
  6. Show/Hide columns by checkbox and cell text
    By ksmoore in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2010, 02:20 PM

Tags for this Thread

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