Hi Team,
Need your help, I have 4 checkboxes in column E.
if user select whichever checkboxes corrensponding sheets needs to get hide or unhide.
check = unhide
uncheck = hide
please suggest how to achieve this task. suggest vba code or event. thanks in advance !
attached image of excel.
I have added checkboxes via below code.
Thanks
mg
Need your help, I have 4 checkboxes in column E.
if user select whichever checkboxes corrensponding sheets needs to get hide or unhide.
check = unhide
uncheck = hide
please suggest how to achieve this task. suggest vba code or event. thanks in advance !
Tasks.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | Sheetnames | Hide/Unhide | |||||
2 | Sheet1 | ||||||
3 | sheet2 | ||||||
4 | sheet3 | ||||||
5 | sheet4 | ||||||
6 | |||||||
Master |
attached image of excel.
I have added checkboxes via below code.
VBA Code:
Sub Addcheckboxes()
'Declare variables and data types
Dim cell, LRow As Single
Dim chkbx As CheckBox
Dim CLeft, CTop, CHeight, CWidth As Double
'Don't refresh or update screen while processing macro, this will make the macro quicker.
Application.ScreenUpdating = False
'Iterate through 2 to last non empty cell
For cell = 2 To 5
'Check if cell in column A is not equal to nothing
If Cells(cell, "A").Value = "" Then
'Save cell dimensions and coordinates of corresponding cell in column E to variables
CLeft = Cells(cell, "E").Left
CTop = Cells(cell, "E").Top
CHeight = Cells(cell, "E").Height
CWidth = Cells(cell, "E").Width
'Create checkbox based on dimension and coordinates data from variables
ActiveSheet.CheckBoxes.Add(CLeft, CTop, CWidth, CHeight).Select
With Selection
.Caption = ""
.Value = xlOff
.Display3DShading = False
End With
End If
Next cell
'Turn on screen refresh
Application.ScreenUpdating = True
End Sub
Thanks
mg