Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
I am trying to use a form control text box to hide tabs in a worksheet
and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
TextBox or CheckBox? Be sure your control name is correct:
"Check Box 1" and "CheckBox1" are two different names CheckBoxes is not a collection, but OLEObjects is. Or ActiveSheet.CheckBox1 = True will also work. "newguy" wrote in message ... I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
It works for me, but I had to rename it CheckBox1_Click.
It can also be reduced to Sub CheckBox1_Click() Sheets("Sheet2").Visible = ActiveSheet.CheckBoxes("Check Box 1").Value = 1 End Sub -- __________________________________ HTH Bob "newguy" wrote in message ... I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
It is a check box and the I right click on the check box the name is
Check Box 1. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
The Checkboxes collection are for checkboxes from the Forms toolbar.
JLGWhiz wrote: TextBox or CheckBox? Be sure your control name is correct: "Check Box 1" and "CheckBox1" are two different names CheckBoxes is not a collection, but OLEObjects is. Or ActiveSheet.CheckBox1 = True will also work. "newguy" wrote in message ... I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
Make sure your procedure is in a General module and assign your macro to the
checkbox. Then you could modify your code so that it doesn't rely on the name of the checkbox. Option Explicit Sub CheckBox_Click() dim CBX as checkbox set cbx = activesheet.checkboxes(application.caller) if cbx.value = xlon then worksheets("sheet2").visible = false else worksheets("Sheet2").visible = true end if end sub newguy wrote: I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
Hi newguy
Try the below code, its working for me. Private Sub CheckBox1_Click() If CheckBox1.Value = True Then Worksheets("Sheet2").Visible = True Else Worksheets("Sheet2").Visible = False End If End Sub "newguy" wrote: I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
Actually, the code seems to work for me. Are you getting any error messages
with it? "newguy" wrote in message ... I am trying to use a form control text box to hide tabs in a worksheet and I cant seem to get it to work any suggestions. Sub CheckBox_Click() If ActiveSheet.CheckBoxes("Check Box 1").Value = 1 Then Sheets("Sheet2").Visible = False Else Sheets("Sheet2").Visible = True End If End Sub |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
The error message I get is "Cannot run the macro 'Test.xlsm!
Sheet1.CheckBox_Click' The Macro may not be available in the workbook or all macros may be disabled." I checked the Trust center and allowed Macros to Run and it is in the General Module. |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Control Text box
You have to enable macros for macros to run.
And it looks like the current macro assigned to this checkbox is not in a general module (or at least the pointer to the macro doesn't think so). Rightclick on the checkbox (not really a textbox, right???) and reassign the correct macro. newguy wrote: The error message I get is "Cannot run the macro 'Test.xlsm! Sheet1.CheckBox_Click' The Macro may not be available in the workbook or all macros may be disabled." I checked the Trust center and allowed Macros to Run and it is in the General Module. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2007 Form Control/ActiveX Control font difference | Excel Discussion (Misc queries) | |||
Can text in check box created with form control be word wrapped? | Excel Programming | |||
problems adding Rich Text Box control to a VBA form? | Excel Programming | |||
Printing the contents of a text control on a user form | Excel Programming | |||
Tool Tip Text for Form control/ Active-X control | Excel Programming |