Disable/Enable Tabstrip on Multitab based on Checkbox value- EXCEL - excel

I have a userform with a multitab containing 8 tabs. I require a user to use checkboxes on tab 6. I'm try to disable the user from selecting the next tab (tab 7) if Checkbox 1 and Checkbox 2 are left unchecked. They should only be able to access the next tab if they select one of the two checkboxes.
Private Sub MultiPage1_Change()
If Failed1.Value = False Or Passed1.Value = False Then
Me.MultiPage1.Pages(7).Enabled = False
Exit Sub
ElseIf Failed1.Value = True Or Passed1.Value = True Then
Me.MultiPage1.Pages(7).Enabled = True
End If
End Sub
I can't quite get the code to work the way I want it to. Any help would be greatly appreciated.
FYI - I'm a VBA n00b.

Me.MultiPageName.Pages(index).enabled = false
Me = the form active where multipage is present
MulitipageName = named multipage
Index = place of the page to enable copied from:http://www.excelforum.com/excel-programming-vba-macros/534056-is-it-possible-to-disable-a-tab-page-on-a-multipage-userform.html

Related

vba both checkbox trigger and dropdown triggers does work together

i have an excel file like the following:
[enter image description here]enter image description here
[1]: https://i.stack.imgur.com/QVe6i.png
this checkbox is being controlled by a trigger and the code is as follows:
Sub CheckBox1_Click()
If Range("CheckBox1").Value = True Then
Range("ET").Rows.Hidden = True
Else:
Range("ET").Rows.Hidden = False
End If
If Range("CheckBox1").Value = True And Range("CheckBox1a").Value = True Then
Range("A50:A53").Rows.Hidden = False
Range("A61:A63").Rows.Hidden = False
Else:
Range("A50:A53").Rows.Hidden = True
Range("A61:A63").Rows.Hidden = True
End If
End sub
if the value of the checkbox is true, it hides rows "A50:A53" and"A61:A63" and unhides when the value is False. works perfect!
On the Same sheet, i have a dropdown that does the same stuff based on the selected option: following is the excel file:
[1]: https://i.stack.imgur.com/EvCt0.png
The same as the CheckBox, the dropdown option also, hides rows "A209:A210", if yes is selected. the triggers for the dropdown is as follows:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Section 4. Testing part 1
If Target.Column = 53 And Target.row = 208 Then
If Target.Value = "Yes" Then
Range("Addition").Rows.Hidden = False
Range("A112:A113").Rows.Hidden = True
ElseIf Target.Value = "No" Then
Range("A112:A113").Rows.Hidden = False
Range("Addition").Rows.Hidden = True
End If
End If
End sub
The issue now is. When i start to work with the CheckBoxes, they work fine however the Dropdown doesn't respond and the same thing happens if the start to work with the dropdown, the checkboxes stop to respond.
Any suggestion or help is highly appreciated!
Instead of CheckBox1_Click try the CheckBox1_Change event. This will ensure the checkbox is updating every time the value changes, even if if doesn't gain or lose focus.
Other than that, you will need to have something in Workbook_Open that checks the default status of those checkboxes and ranges, hiding and showing rows as necessary.
You will also need a separate event just for CheckBox1a. Each CheckBox_Change script only triggers based on the named object in the script's title. For example CheckBox1_Change will only trigger for changes to a matching CheckBox1 object. So if you want things to happen when the user clicks on CheckBox1a then you need a CheckBox1a_Change script.
Finally, you are retrieving and comparing checkbox values using Range("CheckBox1") which is not intended. There is a built in method for accessing these objects through VBA. Each CheckBox is added to the Worksheet object as a member. In the sheet's code module you can write Me.CheckBox1.Value. In an external code module you could write Sheets("Sheet1").CheckBox1.Value.

UserForm ListBox Change not Updating TextBox Visibility

I have a UserForm that has a ListBox named EIDLList and after that there's a TextBox EIDLAmountLabel and EIDLAmountText. I've written a snippet of code that is supposed to grey out both TextBoxes if the ListBox selection is set to "No" but for some reason it's not working. I've tried about 10 different variations using Case, If, UCase, etc and none work. I appreciate any input.
Private Sub EIDLList_Change()
If EIDLList.Value = "No" Then
EIDLAmountLabel.Enabled = False
EIDLAmountText.Enabled = False
Else
EIDLAmountLabel.Enabled = True
EIDLAmountText.Enabled = True
End If
End Sub
I changed the fields from ListBox to ComboBox and now the code works perfectly. Not sure how or why that matters.

Unlock a combo box when an option button is selected

I am trying to unlock a combobox when a option button is enabled. I am using the following code in a module but when I run the code and select the option the combo box remains locked
If Custom = True Then
FromMonth.Locked = False
FromYear.Locked = False
ToMonth.Locked = False
ToYear.Locked = False
End If
I am hoping to find a way to simultaneously click the option button in the userform and have it unlock the combo boxes next to them
You can use the option button change event, and make sure to add the code into userform code module and not the normal module
Your code can be something like this
Private Sub Custom_Change()
FromMonth.Locked = Not Custom.Value
FromYear.Locked = Not Custom.Value
ToMonth.Locked = Not Custom.Value
ToYear.Locked = Not Custom.Value
End Sub

Disable specific sheet ("ply") right click option using Excel VBA

I'm trying to disable (or hide) specific right click options on the Excel sheet/tab menu. I don't want to disable the entire menu per this thread.
I've tried in both Excel 2010 & 2016, same result. The code runs fine but the options in the sheet right click menu are still enabled. I've tried using the control's name and ID to no avail.
Private Sub Worksheet_Activate()
Application.CommandBars("cell").Controls("cut").Enabled = False 'Works
With Application.CommandBars("Ply")
.Controls("Insert...").Enabled = False
.Controls("&Select All Sheets").Enabled = False
.Controls("Select All Sheets").Enabled = False
.FindControl(ID:=946).Enabled = False '&Select All Sheets ID:946
'.Enabled = False 'Works but don't want entire menu disabled
End With
End Sub
After code, options are still enabled:
Thanks in advance.

Hide or disable a button if the sheet is protected

For my form I need to hide or disable a textbox with a on-click delete macro attached to it when the sheet is protected. I'm talking about excel's build-in protection system. I've looked at several tutorials but I can't seem to get it to work properly.
I tried multiple things including this:
If ActiveSheet.ProtectContents = True Then
TextBox1.Visible = False
Else
TextBox1.Visible = True
End If
Any idea how to do this?
Change
If ActiveSheet.ProtectContents = True Then
TextBox1.Visible = False
Else
TextBox1.Visible = True
End If
To
If ActiveSheet.ProtectContents = True Then
ActiveSheet.TextBox1.Visible = False
Else
ActiveSheet.TextBox1.Visible = True
End If
You are not declaring where the textbox is. This will fix it
It is not clear whether the textbox is embedded in the worksheet or in a userform.
If in the worksheet is it a text box based on a shape? These are created from the INSERT tab on the Ribbon.
Or is this an ActiveX textbox? These are created from the DEVELOPER tab on the Ribbon.
If on the other hand, you are referring to a textbox on a userform then you can use the following code (assuming the userform code name is UserForm1):
UserForm1.Controls("NameOfYourTextBox").Visible = Not ActiveSheet.ProtectContents

Resources