Hi,
I have been trying to get a code to work on my spreadsheet that runs as soon as you open the spreadsheet file. The code allows for the grouped rows to be seen or not seen depending on the user but doesn't allow any of the cells to be edited unless you have the password (basically like a protected sheet).
I have attached screenshot of the spreadsheet as well as the code I have been trying to manipulate. I'm very new to coding and only teaching myself (with the help of this forum and youtube) so go easy on me if I have the total wrong code or something.
Thanks
Regards
Norto
here is the code.
Sub Workbook_Open()
Dim Dosomething()
Dim xSh As Worksheet
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()
Dim OnEdit
Dim EnableOutlining()
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
Dim xPws As String
xPws = Application.InputBox("Password:", xTitleId, "", Type:=2)
xWs.Protect Password:=xPws, Userinterfaceonly:=True
xWs.EnableOutlining = True
End Sub
Here is the front page of the sheet.
I have been trying to get a code to work on my spreadsheet that runs as soon as you open the spreadsheet file. The code allows for the grouped rows to be seen or not seen depending on the user but doesn't allow any of the cells to be edited unless you have the password (basically like a protected sheet).
I have attached screenshot of the spreadsheet as well as the code I have been trying to manipulate. I'm very new to coding and only teaching myself (with the help of this forum and youtube) so go easy on me if I have the total wrong code or something.
Thanks
Regards
Norto
here is the code.
Sub Workbook_Open()
Dim Dosomething()
Dim xSh As Worksheet
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()
Dim OnEdit
Dim EnableOutlining()
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
Dim xPws As String
xPws = Application.InputBox("Password:", xTitleId, "", Type:=2)
xWs.Protect Password:=xPws, Userinterfaceonly:=True
xWs.EnableOutlining = True
End Sub
Here is the front page of the sheet.