+ Reply to Thread
Results 1 to 9 of 9

allow three Toggle button only at a time and capture the value in a range

  1. #1
    Registered User
    Join Date
    06-05-2014
    Posts
    4

    Post allow three Toggle button only at a time and capture the value in a range

    Hi Team,

    I have 20 Toggle buttons in a form, i want user to select max 3 toggle buttons only, and then capture the Toggle button value in a range.

    Below is the code which i am currently working and needing help to resolve this.

    in class module:

    Please Login or Register  to view this content.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------

    In Form:


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi there,

    When you say:

    and then capture the Toggle button value in a range
    do you mean that you want to capture the values of the three "pressed" ToggleButtons? Do you want to store three separate values in three cells in a specified Range?

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    06-05-2014
    Posts
    4

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi Greg,

    Yes, want to store the vale in three cells in a specified range

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi again,

    I'm not at my computer at the moment but I will have something to send you later today.

    Regards,

    Greg M

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi there,

    On reflection, I don't think that returning the Value properties of the selected ToggleButtons will be very useful (after all, they'll obviously all be TRUE! ), so instead I've returned the values of the Caption properties of the selected ToggleButtons.

    Take a look at the attached workbook and see if it does what you need. It uses the following code in a standard VBA CodeModule:

    Please Login or Register  to view this content.
    the following code in the VBA CodeModule of the UserForm:

    Please Login or Register  to view this content.
    and the following code in the VBA CodeModule for the ToggleButton Class:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-05-2014
    Posts
    4

    Re: allow three Toggle button only at a time and capture the value in a range

    thank you Greg, you have resolved my issue. Thank you..Thank you..Thank you..Thank you..a big thank you

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi again,

    Many thanks for your feedback.

    You're welcome, you're welcome, you're welcome - glad I was able to help.

    Regards,

    Greg M

  8. #8
    Registered User
    Join Date
    06-05-2014
    Posts
    4

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi Greg,

    I created one more form in the same workbook you provided and few more toggle buttons (so two form with toggle buttons) , i copied the code from your form, however second form which i created throws me run time error, could you please advise if i need to change something in the code. Also in the code : (Const sSELECTED_BUTTONS As String = "A1:A3" ), if i change it to "A1:C1" it still captures the value in "A1:A3". please advise

    Thank you again for all your help

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: allow three Toggle button only at a time and capture the value in a range

    Hi again,

    The line

    Please Login or Register  to view this content.
    assumes that the target range is part of a single column.


    If the target range is part of a single row you should use

    Please Login or Register  to view this content.

    You could possibly use the following (untested) code, but my personal preference is always to specify both the row and the column of the target range

    Please Login or Register  to view this content.

    As far as the other UserForm is concerned, I would need to see it before I could make any meaningful suggestion. Can you post it here?

    Regards,

    Greg M
    Last edited by Greg M; 09-11-2020 at 07:17 PM. Reason: Typo corrected

+ 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. How do I insert a toggle button to cover a cell range?
    By Yellowchalkie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-22-2019, 07:32 PM
  2. [SOLVED] how do i make a toggle button change other toggle buttons value to false
    By kevinu in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-10-2018, 04:19 PM
  3. [SOLVED] Stop Time Button to capture Time Spent
    By 323100N in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2017, 09:25 AM
  4. [SOLVED] ActiveX Toggle Button - Only ONE at a time
    By ericbartha in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-24-2014, 03:23 PM
  5. Capture System Time On button click
    By sap_iias in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2014, 10:45 AM
  6. Replies: 1
    Last Post: 02-13-2014, 10:55 PM
  7. How do I toggle a button across a range of columns
    By sodaboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2005, 09:05 PM

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