Hide Checkbox in Excel using VBA or IF formula?

xrak

New Member
Joined
Feb 4, 2020
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Please Help: How to Hide Checkbox in Excel using VBA or IF formula?

FOR EXAMPLE: IF C23 = “” THAN HIDE CHECK BOX 1
"" means the cell is empty
I want the CHECK BOX 1 to become visible after I write something in the cell C23

THANK YOU IN ADVANCE!!!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi, you can do this with a Worksheet_Change macro.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$23" Then
     If IsEmpty(Cells(23, 3)) Then
        Sheet1.CheckBoxes("Check Box 1").Visible = vbFalse
     Else
        Sheet1.CheckBoxes("Check Box 1").Visible = vbTrue
     End If
End If
End Sub
You need to put this in the Sheet's code - right click the Sheet and View Code, as below:
1580804430154.png


When C23 is deleted/empty the Check Box will hide and when text is entered it will appear again.
 
Upvote 0
Thank you for your time! I really appreciate this!
But unfortunately this formula does not work.
 

Attachments

  • error.PNG
    error.PNG
    59.8 KB · Views: 267
Upvote 0
You need to remove the VBA Code: as it's not part of the code.
 
Upvote 0
Sorry. My mistake.
I did remove it - and now it works great!

Thank you very much!!!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Would you please help me do one more thing?
I planned to make several chekboxes and several cells. I tried to paste this code again - changing cell# and checkbox# - but it fails.
How can I write the code correctly - so that I can create 50 such cells, starting from C23 - checkbox1 to C73 - checkbox50
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C23:C73")) Is Nothing Then
      Me.CheckBoxes("Check Box " & Target.Row - 22).Visible = Target.Value <> ""
   End If
End Sub
 
Upvote 0
What was the error message & number & what row did you change?
 
Upvote 0

Forum statistics

Threads
1,224,722
Messages
6,180,559
Members
452,987
Latest member
mrfitness_79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top