+ Reply to Thread
Results 1 to 9 of 9

UserForm Checkbox Range/Cell Address

  1. #1
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    UserForm Checkbox Range/Cell Address

    As part of a bigger project, I'm working to have users enable/disable a number of Custom Menu items. The theory here is the user will open a userform and then check the boxes/menus they want enabled and the Menu/Ribbon will then reload with those items.

    So..... in getting started, and its been over a year since I have done much and forgot half of what I learned...

    I'm setting up a UserForm that will list the Departments of my Company. I have them listed in Column A on worksheet. And I want to show a 0 or 1 in Column B depending on what they select. I will then move onto reading Column B when Excel opens to set the Visible status of a Menu item. This will all be part of Addin eventually, so I'm currently not to concerned with hiding the worksheet at the moment.

    This is part of the Userform info right now, and I'm struggling to figure how to add the 1 or 0 into Column B for each item that is selected or unselected. It's probably easier than I'm making it out to be, but I seem to have forgetten so much.

    Please Login or Register  to view this content.
    Last edited by ptmuldoon; 05-26-2017 at 08:28 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: UserForm Checkbox Range/Cell Address

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: UserForm Checkbox Range/Cell Address

    Sure.

    Here is a sample workbook, and its pretty rough at the moment. As the fog lifts, I think I need to maybe include a 2nd hidden field in the check box that includes the Items Cell Address. And then with the OnClick, read the address, use an Offset and then post a value to column B. But i'm still pretty rusty.

    Note, I'll correct the fixed Column A range as well eventually, but still trying to remember how to do some things.
    Last edited by ptmuldoon; 05-27-2017 at 09:23 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: UserForm Checkbox Range/Cell Address

    I made some further progress this morning and will try and work on this more later today.

    I have the userform now using a multicolumn, multiselect. But I can't seem to figure out exactly how to Update Column B to show Yes or No for being 'Active'

    Currently, with the OnClick, I am searching column A for a match on the selected items. But it seems to only update 1 item and not each selected items.

    The updated code and sample attached.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ptmuldoon; 05-27-2017 at 09:55 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: UserForm Checkbox Range/Cell Address

    I just can not seem to figure out why this doesn't work.

    The userform listbox is a multicolumn, multiselect is generated from Columns A and B on the worksheet. And the user should then be able to select the items they want and Column B should then Update to Yes for a Checked Item and No for an Unchecked.

    This in the onclick code.

    Please Login or Register  to view this content.
    Last edited by ptmuldoon; 05-27-2017 at 03:56 PM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: UserForm Checkbox Range/Cell Address

    When you change the listbox it deselects the selected items.

    For example, let's say you've selected 'Audit' and 'HR'.

    At the first iteration of this loop the cell next to 'Audit' will be set to Yes but it will also 'reset' the listbox so 'HR' will not be selected anymore.
    Please Login or Register  to view this content.
    One way of avoiding this would be to use List to populate the listbox rather than RowSource, however if you use List, or any method other than RowSource, to populate the listbox you can't have headers in the listbox itself.

  7. #7
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: UserForm Checkbox Range/Cell Address

    Hello ptmuldoon,

    I think you just complicate the thing too much. I would avoid the multi column listbox making the loop mych simple ( I suppose the departments are and stay fixed).
    Well, I attach a simple solution to your posted example for you (hope I get your intention correctly) to push you little bit. If it is not what you wanted and want to dig it and find out by yourself, just ignore the attachment.

    sysss
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: UserForm Checkbox Range/Cell Address

    Quote Originally Posted by sysss View Post
    Hello ptmuldoon,

    I think you just complicate the thing too much. I would avoid the multi column listbox making the loop mych simple ( I suppose the departments are and stay fixed).
    Well, I attach a simple solution to your posted example for you (hope I get your intention correctly) to push you little bit. If it is not what you wanted and want to dig it and find out by yourself, just ignore the attachment.

    sysss
    Sysss. You pretty much got exacty what I'm trying to accomplish. The only thing I want to work to change is that instead of having 2 separate forms like you did, but have the main listbox open with any items already active shown as selected.... ie, in this case those with the value of 1. I see your 2nd form is doing that when it opens, so I I just need to figure out how to modify that some into the initialize of the listbox form

  9. #9
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: UserForm Checkbox Range/Cell Address

    Hi,

    this should be it (in my example to the first userform):

    Please Login or Register  to view this content.

+ 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. Userform Checkbox to cell
    By WhiteWaterMatt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2016, 06:41 AM
  2. [SOLVED] Userform - checkbox & texbox value in range
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-02-2014, 02:44 PM
  3. UserForm Checkbox populate last empty row of range
    By djsouljah in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2013, 06:14 PM
  4. Replies: 0
    Last Post: 11-15-2012, 12:29 PM
  5. Reference checkbox using linked cell address
    By chewie in forum Excel General
    Replies: 3
    Last Post: 06-02-2011, 02:11 PM
  6. Delete Range when checkbox in Userform is Selected
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2010, 03:13 AM
  7. referencing a checkbox cell address in a worksheet
    By Erik Andreassen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2005, 12:05 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