Checkbox validations

Nikhil2803

New Member
Joined
Jul 18, 2023
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hi Team, I am new to Excel VBA and macros. I am working on one request. There are two sheets in an excel sheet. under sheet 1, there are few checkboxes and there are few columns in sheet 2. The requirement is: if i check the checkbox in sheet 1, some x,y and z columns under sheet 2 should be disabled. Please help me how to achieve this. May be using Macros.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Team, I am new to Excel VBA and macros. I am working on one request. There are two sheets in an excel sheet. under sheet 1, there are few checkboxes and there are few columns in sheet 2. The requirement is: if i check the checkbox in sheet 1, some x,y and z columns under sheet 2 should be disabled. Please help me how to achieve this. May be using Macros.
What do you mean or intend when you say "disable" columns? Hide them? Lock and Protect the Sheet? Prevent entries in these columns without Locking the Sheet? Please clarify
 
Upvote 0
What do you mean or intend when you say "disable" columns? Hide them? Lock and Protect the Sheet? Prevent entries in these columns without Locking the Sheet? Please clarify
Sorry for the confusion. I just need to hide the columns on the basic of checkbox
 
Upvote 0
Here is VBA code tied to the click event of a CheckBox on Sheet1
I selects (navigates to) Sheet2 and hides/unhides columns X,Y, & Z
You may not want it to jump from Sheet1 to Sheet2, but hide/unhide the columns regardless.
Please provide feedback.

VBA Code:
Sub HideUnhideCol_Click()
'
' CheckBox26_Click Macro
'

'
    Sheets("Sheet2").Select
    ActiveWindow.ScrollColumn = 2
    Columns("X:Z").Select
    
    With Selection.EntireColumn
      .Hidden = Not (.Hidden)
    End With
End Sub
 
Upvote 0
Solution
Snapshot of the Checkbox on Sheet1 - it is linked to the macro code in the previous reply.
1689702103747.png
 
Upvote 0
Here is VBA code tied to the click event of a CheckBox on Sheet1
I selects (navigates to) Sheet2 and hides/unhides columns X,Y, & Z
You may not want it to jump from Sheet1 to Sheet2, but hide/unhide the columns regardless.
Please provide feedback.

VBA Code:
Sub HideUnhideCol_Click()
'
' CheckBox26_Click Macro
'

'
    Sheets("Sheet2").Select
    ActiveWindow.ScrollColumn = 2
    Columns("X:Z").Select
   
    With Selection.EntireColumn
      .Hidden = Not (.Hidden)
    End With
End Sub
Perfect. Thank you
 
Upvote 0
This easy to setup.
- record the macro
- add the checkbox
- link the macro to the checkbox
- edit the macro as needed
 
Upvote 0
If your problem/needs are resolved please flag your Post as "Solved". Muchas gracias!
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,418
Members
449,449
Latest member
Quiet_Nectarine_

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