+ Reply to Thread
Results 1 to 5 of 5

Linking selected option from Combo Box to set Cell Selection in UserForm

  1. #1
    Registered User
    Join Date
    01-27-2021
    Location
    Leicestershire, UK
    MS-Off Ver
    MS2016
    Posts
    3

    Linking selected option from Combo Box to set Cell Selection in UserForm

    Hi all

    I've created a Userform to give an admin user a mini dashboard to manage various workbook properties, including worksheet and workbook protection.

    One of the options is for the user to password protect all worksheets, and I thought I could use a ComboBox for the user to select their preferred cell selection option.

    So, on the UserForm I have the following:

    A textbox to enter a password [tbxWSPW]
    A command button to protect the worksheets [cmdWSProtect]
    and a ComboBox [cbxCellSelection] to choose one of three cell options - xlNoRestrictions, xlUnlockedCells and xlNoSlection.

    The code I'm using is as follows:

    Please Login or Register  to view this content.
    But, when I run this I keep getting a Type Mismatch error on the ws.EnableSelection line.

    I have two questions:

    1. How do I fix the above?
    2. If I wanted to control the other properties (for example DrawingObjects, Scenarios etc), could I do this using checkboxes (ie: ticked for True, unticked for False), and how would I code this?

    Many thanks everyone
    Stephen

  2. #2
    Registered User
    Join Date
    04-19-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    O365, Win10 and Mac
    Posts
    47

    Re: Linking selected option from Combo Box to set Cell Selection in UserForm

    Possible values for EnableSelection are

    xlNoRestrictions ' Value 0
    xlNoSelection ' Value -4142
    xlUnlockedCells ' Value 1

    Does your text box contain one of those values? If not you will get a match error.

  3. #3
    Registered User
    Join Date
    01-27-2021
    Location
    Leicestershire, UK
    MS-Off Ver
    MS2016
    Posts
    3

    Re: Linking selected option from Combo Box to set Cell Selection in UserForm

    Hi Corbett

    Thanks for your reply! No, my ComboBox contains 'xlNoRestrictions', 'xlUnlockedCells' and 'xlNoSelection', but not the numeric values you've posted. Is there a way around that so that the text options are available instead of the numeric ones?

    Thanks
    Stephen

  4. #4
    Registered User
    Join Date
    04-19-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    O365, Win10 and Mac
    Posts
    47

    Re: Linking selected option from Combo Box to set Cell Selection in UserForm

    There are a good number of ways of going about it. Perhaps not the most elegant but maybe the most readable would be a select clause, along the lines of

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-27-2021
    Location
    Leicestershire, UK
    MS-Off Ver
    MS2016
    Posts
    3

    Re: Linking selected option from Combo Box to set Cell Selection in UserForm

    Hi Corbett

    That works perfectly, thanks for the reply to this it's much appreciated

    KR
    Stephen

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] linking combo boxes based on a selected day
    By Brazz1 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-13-2019, 05:08 AM
  2. [SOLVED] Userform with Combo box to paste date to cell range based on each option in drop down
    By Sabrina68 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2016, 11:03 AM
  3. Replies: 1
    Last Post: 08-07-2015, 12:26 AM
  4. Returning the row number of the option after the selected option in a userform combobox
    By rep67439fgs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2014, 08:07 AM
  5. [SOLVED] Excel 2010 VBA – Combo Box Options– Clear cell/box in 2nd Combo when 1st Combo selected
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 07:25 PM
  6. Using IF code for a combo box to display different cells based on option selected
    By ScottBeatty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2013, 10:36 AM
  7. Activate Print option with a userform where selected Sheet check box option available..
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 08:19 AM

Tags for this Thread

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