Using checkboxes

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Ok so ideally what I want to do is use checkboxes to determine what columns are hidden/unhidden on another sheet.

Currently I do this by using code like

Code:
If Sheets("Sheet1").Location = False Then
Sheets("sheet2").Range("c3").EntireColumn.Hidden = True
Sheets("sheet2").Range("c3").Offset(0, 1).EntireColumn.Hidden = True
Else
Sheets("sheet2").Range("c3").EntireColumn.Hidden = False
Sheets("sheet2").Range("c3").Offset(0, 1).EntireColumn.Hidden = False
End If
with Location being the name of a checkbox.


But what I would like to do, is instead, use code to loop through all the checkboxes on sheet1 and use either the checkbox name or caption, to find that value in row 3 of sheet2 and hide that column and the column to the right.

This way if any columns are added to sheet 2 I only have to add a checkbox with a matching name/caption
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Not sure I follow but maybe try "Application.Caller" with "Form" check boxes. You could use the check box name to specify a range if you devise a logical naming scheme or you could use the "TopLeftCell" property of the check box with "Offset" to specify relative ranges.

Hope this helps.

Gary

Code:
Public Sub Test()

'Place a form check box on a worksheet and use the "Macro Assign" button
'to specify this procedure to run when check box is selected

MsgBox Application.Caller

MsgBox ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address

MsgBox ActiveSheet.Shapes(Application.Caller).ControlFormat.Value

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,683
Members
452,937
Latest member
Bhg1984

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