elgatnegre
New Member
- Joined
- Nov 19, 2014
- Messages
- 7
Given two workbooks named as follows:
"W01_Clients.xls"
"W02_Macros.xls"
I wrote a piece of code in a module of the workbook "W02_Macros" to make a sheet (named "S02_AuxBackOffice") which it is placed in the workbook "W01_Clients.xls" to be visible or invisible when runing the code from the first workbook ("W02_Macros").
The code first checks the value in the cell "D6" of the sheet in which the code is placed and from which the code is meant to be called ("Sheet1" of the workbook "W02_Macros") and works as follows:
(the following code is written in a module of the workbook "W02_Macros")
Sub ShowHideBackOfficeSheets()
With Sheets("Sheet1")
If Range("D6").Value = True Then
Workbooks("W01_Clients.xls").Worksheets("S02_AuxBackOffice").Visible = True
Else
Workbooks("W01_Clients.xls").Worksheets("S02_AuxBackOffice").Visible = False
End If
End With
End Sub
As you can see, the code assumes that if the value found in cell "D6" of the "Sheet1" is = "True", then the macro will make visible the sheet I want to see ("S02_AuxBackOffice") which is placed in the other workbook ("W01_Clients.xls"). Otherwise, if the value in the cell "D6" is not = "True" (e.g. "D6" = "False") then the macro will make the same sheet invisible.
This works as follows: I use a check button linked to the macro (so that runs de code every time I click on it in order to check or uncheck the button) and which besides is linked to the cell "D6" (giving a value = "True" to the cell when the button is checked and False otherwise). Therefore, every time the user checks or unchecks the button from the workbook "W02_Macros", there are two actions that will start automatically: first, the value of the cell "D6" of the "Sheet1" changes, and second, the macro "ShowHideBackOfficeSheets()" will run and so it will make the "S02_AuxBackOffice" visible or invisible in the workbook "W01_Clients.xls".
The method works correctly, but the thing is that now I want to change the way to call (activate) the macro in order to change the state of the sheet from visible to invisible and viceversa. I don't want to do it through a check button anymore, but I want to do it by using a drop-down validation menu, placed in the cell "D6", from which the user can select between two options: 'show sheet' and 'hide sheet' BUT knowing these words from the drop-down validation menu are actually going to be shown in the language of the user (english='show sheet', spanish='mostrar hoja', etc.).
The target I need to achieve is that by every change in the drop-down menu placed in the cell "D6" of the "Sheet1" in the workbook "W02_Macros" the code would automatically run in order to make the sheet of the workbook "W01_Clients.xls" (the sheet named "S02_AuxBackOffice") visible or invisible as desired by the user. Please note that I have defined and named a range in the "Sheet2" of the workbook "W02_Macros" in order to create the validation list in the "Sheet1"and which contains the names of the cases included in the validation list in the language chosen by the user (english='show sheet', spanish='mostrar hoja', etc.).
Anyone can help me out?
"W01_Clients.xls"
"W02_Macros.xls"
I wrote a piece of code in a module of the workbook "W02_Macros" to make a sheet (named "S02_AuxBackOffice") which it is placed in the workbook "W01_Clients.xls" to be visible or invisible when runing the code from the first workbook ("W02_Macros").
The code first checks the value in the cell "D6" of the sheet in which the code is placed and from which the code is meant to be called ("Sheet1" of the workbook "W02_Macros") and works as follows:
(the following code is written in a module of the workbook "W02_Macros")
Sub ShowHideBackOfficeSheets()
With Sheets("Sheet1")
If Range("D6").Value = True Then
Workbooks("W01_Clients.xls").Worksheets("S02_AuxBackOffice").Visible = True
Else
Workbooks("W01_Clients.xls").Worksheets("S02_AuxBackOffice").Visible = False
End If
End With
End Sub
As you can see, the code assumes that if the value found in cell "D6" of the "Sheet1" is = "True", then the macro will make visible the sheet I want to see ("S02_AuxBackOffice") which is placed in the other workbook ("W01_Clients.xls"). Otherwise, if the value in the cell "D6" is not = "True" (e.g. "D6" = "False") then the macro will make the same sheet invisible.
This works as follows: I use a check button linked to the macro (so that runs de code every time I click on it in order to check or uncheck the button) and which besides is linked to the cell "D6" (giving a value = "True" to the cell when the button is checked and False otherwise). Therefore, every time the user checks or unchecks the button from the workbook "W02_Macros", there are two actions that will start automatically: first, the value of the cell "D6" of the "Sheet1" changes, and second, the macro "ShowHideBackOfficeSheets()" will run and so it will make the "S02_AuxBackOffice" visible or invisible in the workbook "W01_Clients.xls".
The method works correctly, but the thing is that now I want to change the way to call (activate) the macro in order to change the state of the sheet from visible to invisible and viceversa. I don't want to do it through a check button anymore, but I want to do it by using a drop-down validation menu, placed in the cell "D6", from which the user can select between two options: 'show sheet' and 'hide sheet' BUT knowing these words from the drop-down validation menu are actually going to be shown in the language of the user (english='show sheet', spanish='mostrar hoja', etc.).
The target I need to achieve is that by every change in the drop-down menu placed in the cell "D6" of the "Sheet1" in the workbook "W02_Macros" the code would automatically run in order to make the sheet of the workbook "W01_Clients.xls" (the sheet named "S02_AuxBackOffice") visible or invisible as desired by the user. Please note that I have defined and named a range in the "Sheet2" of the workbook "W02_Macros" in order to create the validation list in the "Sheet1"and which contains the names of the cases included in the validation list in the language chosen by the user (english='show sheet', spanish='mostrar hoja', etc.).
Anyone can help me out?