Hi,
This is driving me crazy!
The idea...
The user selects a value in a drop-down list, which triggers some sheets to be hidden-unhidden, and fills-up a cell with a message of the outcome.
I want to use a single UDF to which I pass variables as needed (i.e. re-use the UDF for each sheet to hide-unhide).
The setup...
In worksheet "Module", the user clicks on cell C29 (named: "StatusSelected") where there is a drop-down list.
This drop-down list contains 2 items to choose from: "StatusEnabled" and "StatusDisabled".
In cell B36, I have a formula which gets me the active name of a specific sheet based on some other things which happen. For instance, the cell shows "Data Access", which is the name of the sheet I want to be able to hide-unhide when the user selects an item in the drop-down list.
In cell C36, I placed my UDF which uses both C29 (aka "StatusSelected") and C36 to get the name of the actual sheets to hide/unhide.
The B36 and C36 couple is repeated (in other cells) for several sheets I want to hide/unhide at the same time that C29 changes.
The point...
I need to be able to pass the name of the tab (i.e. "TabName") as a variable. In other words, the name of the tab cannot be encoded in the UDF.
The problem...
The UDF returns the proper messages depending on what item is selected by the user... but... the sheet targeted is not affected by the choice of item from the drop-down list.
I could verify that "TabName" is properly assigned, but the " Sheets(TabName).Visible = xlSheetVeryHidden " does not seem to reach the tab or, in any case, it has no effect on the tab.
The UDF call in C36...
=MODULE_Activation(B36,Modules_DataAccess,Global_ModuleEnabled,Global_ModuleDisabled)
The UDF...
I placed it in the "Module1" since I would like to have all my UDFs in a single location (if possible).
Function MODULE_Activation(TabName As String, StatusSelected As String, StatusEnabled As String, StatusDisabled As String)
' If the user selected either StatusEnabled or StatusDisabled in the drop-down list...
If StatusSelected = StatusEnabled Or StatusSelected = StatusDisabled Then
' If the user selected StatusEnabled in the drop-down list...
If StatusSelected = StatusEnabled Then
' Make the worksheet "Visible"
Sheets(TabName).Visible = xlSheetVisible
' Advise of the new status as "Visible"
MODULE_Activation = "Tab """ & TabName & """ is visible and related functionalities are activated"
' If the user selected StatusDisabled in the drop-down list...
Else
' Make the following worksheet "Hidden"
' To keep the integrity of the template, use "xlSheetVeryHidden"
' This removes the possibility to unhide via the User Interface
' Alternatively, use "xlSheetHidden" to be able to unhide via the User Interface
Sheets(TabName).Visible = xlSheetVeryHidden
' Advise of the new status as "Hidden"
MODULE_Activation = "Tab """ & TabName & """ is hidden and related functionalities are disactivated"
End If
' If the user did not select either StatusEnabled or StatusDisabled in the drop-down list...
Else
' Advise that the status selected is not valid (not equal to either StatusEnabled or StatusDisabled)
MODULE_Activation = "The status selected is not valid"
End If
End Function
Any help to make it work would be greatly appreciated...
In advance, thank you!
This is driving me crazy!
The idea...
The user selects a value in a drop-down list, which triggers some sheets to be hidden-unhidden, and fills-up a cell with a message of the outcome.
I want to use a single UDF to which I pass variables as needed (i.e. re-use the UDF for each sheet to hide-unhide).
The setup...
In worksheet "Module", the user clicks on cell C29 (named: "StatusSelected") where there is a drop-down list.
This drop-down list contains 2 items to choose from: "StatusEnabled" and "StatusDisabled".
In cell B36, I have a formula which gets me the active name of a specific sheet based on some other things which happen. For instance, the cell shows "Data Access", which is the name of the sheet I want to be able to hide-unhide when the user selects an item in the drop-down list.
In cell C36, I placed my UDF which uses both C29 (aka "StatusSelected") and C36 to get the name of the actual sheets to hide/unhide.
The B36 and C36 couple is repeated (in other cells) for several sheets I want to hide/unhide at the same time that C29 changes.
The point...
I need to be able to pass the name of the tab (i.e. "TabName") as a variable. In other words, the name of the tab cannot be encoded in the UDF.
The problem...
The UDF returns the proper messages depending on what item is selected by the user... but... the sheet targeted is not affected by the choice of item from the drop-down list.
I could verify that "TabName" is properly assigned, but the " Sheets(TabName).Visible = xlSheetVeryHidden " does not seem to reach the tab or, in any case, it has no effect on the tab.
The UDF call in C36...
=MODULE_Activation(B36,Modules_DataAccess,Global_ModuleEnabled,Global_ModuleDisabled)
The UDF...
I placed it in the "Module1" since I would like to have all my UDFs in a single location (if possible).
Function MODULE_Activation(TabName As String, StatusSelected As String, StatusEnabled As String, StatusDisabled As String)
' If the user selected either StatusEnabled or StatusDisabled in the drop-down list...
If StatusSelected = StatusEnabled Or StatusSelected = StatusDisabled Then
' If the user selected StatusEnabled in the drop-down list...
If StatusSelected = StatusEnabled Then
' Make the worksheet "Visible"
Sheets(TabName).Visible = xlSheetVisible
' Advise of the new status as "Visible"
MODULE_Activation = "Tab """ & TabName & """ is visible and related functionalities are activated"
' If the user selected StatusDisabled in the drop-down list...
Else
' Make the following worksheet "Hidden"
' To keep the integrity of the template, use "xlSheetVeryHidden"
' This removes the possibility to unhide via the User Interface
' Alternatively, use "xlSheetHidden" to be able to unhide via the User Interface
Sheets(TabName).Visible = xlSheetVeryHidden
' Advise of the new status as "Hidden"
MODULE_Activation = "Tab """ & TabName & """ is hidden and related functionalities are disactivated"
End If
' If the user did not select either StatusEnabled or StatusDisabled in the drop-down list...
Else
' Advise that the status selected is not valid (not equal to either StatusEnabled or StatusDisabled)
MODULE_Activation = "The status selected is not valid"
End If
End Function
Any help to make it work would be greatly appreciated...
In advance, thank you!