Hide Column When Checkbox (Forms Control) is checked

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,516
Office Version
  1. 2016
Platform
  1. Windows
Hello All,

The checkbox (Forms Control) is linked with cell D2 which returns True when the checkbox is checked and False when its unchecked


1582797594181.png


Then I am using the below code to hide/unhide rows

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
If Range("D2").Value = True Then Rows("1:1").EntireRow.Hidden = True
If Range("D2").Value = False Then Rows("1:1").EntireRow.Hidden = False


End Sub

The problem is every time I need to edit any cell in the worksheet for the event to trigger.
Is there any possibility to hide or unhide rows as soon as the checkbox is checked or unchecked.

I also tried the selection change event but for that too I need to click on a cell for the event to trigger.

Any help would be appreciated.

Regards,

Humayun
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Glad to hear that & thanks for the feedback
 
Upvote 0
Just one more thing...

If i want to hide rows 1:3 & 5:6.... ??

I tired this but not working

Rows("1:3,5:6").Hidden = Shp.ControlFormat.Value = 1

EDIT:


Got it working like this :)

Range("1:3,5:6").EntireRow.Hidden = Shp.ControlFormat.Value = 1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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