I have a worksheet for employees to report their time and expenses. In this worksheet, I added an Activex combobox list for a particular employee to select his/her name from (the list references the employee names from another sheet that will be hidden).
I would like the time and expense worksheet to automatically rename to some abbreviation of the employee name selected from the combobox when the worksheet is protected.
I was able to write working code that updates the sheet name based on the linkedcell that the combobox selection outputs to, however this will not work when the sheet is protected because Excel doesn't seem to recognize the selectionchange. My question: How can I make sure the worksheet name auto updates when the sheet is protected? I'm pretty sure there is a way to use Private Sub ComboBox41_Click() to do what I want, but I'm not sure how to do it.
I've tried auto renaming the worksheet using data validation list, form combo box, and activex combo box and I run into the same problem when protecting the sheet. That is, the selection event is not being recognized when sheet protection is on.
The code I currently have is copied below (it does work when the sheet isn't protected). Note that N9 references a formula based off of the linkedcell that abbreviates the employee name.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Set Target = Range("N9")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Left(Target, 31)
Exit Sub
Badname:
MsgBox "Please revise the entry in N9." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
Range("N9").Activate
End Sub
I've looked for hours and have not found similar posts. Thanks so much for the help.
- Nina
Bookmarks