Results 1 to 8 of 8

Code to rename worksheet based on combobox selection that works with protected sheet

Threaded View

  1. #1
    Registered User
    Join Date
    08-05-2013
    Location
    DC, USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Code to rename worksheet based on combobox selection that works with protected sheet

    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
    Last edited by natkin; 08-05-2013 at 03:16 PM. Reason: Updated title and content

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Based on userform combobox selection find text on worksheet
    By afpPaul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2012, 08:07 AM
  2. [SOLVED] Change Worksheet based on ComboBox selection
    By dagindi in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-15-2012, 10:19 AM
  3. ActiveX ComboBox listfillrange automatic update
    By Makafi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2009, 01:54 PM
  4. Populate a activeX combobox from a selection of another combobox
    By ptramel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-28-2009, 06:50 PM
  5. ActiveX ComboBox selection writes multiple cells
    By darmstrong in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-30-2007, 10:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1