Results 1 to 6 of 6

Userform, multiple sets of ToggleButtons, rationalise to single code?

Threaded View

  1. #1
    Registered User
    Join Date
    03-04-2012
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Userform, multiple sets of ToggleButtons, rationalise to single code?

    Hello

    I have a multipage userform which includes around 50 sets of 3 togglebuttons. Each set of 3 togglebuttons are within a frame and the frame includes a textbox and a label. The 3 toggle buttons are option answers to questions and the user must select one of the three togglebuttons for their answer of 'yes', 'no' or 'not applicable'. On selecting the correct button, the answer is placed into a specific cell on the worksheet.

    I have the following code, which works fine for one set of the buttons:
    '###################################
    '##########  5.1 YES NO NA BUTTONS ############
    '###################################
    Private Sub ToggleButton51Y_Click()
    If ToggleButton51Y.Value = True Then
        Sheets("Input").Range("k71") = "Yes"
        
        ToggleButton51Y.BackColor = RGB(20, 255, 3)
        ToggleButton51N.Value = False
        ToggleButton51N.BackColor = &H8000000F
        ToggleButton51NA.Value = False
        ToggleButton51NA.BackColor = &H8000000F
    
    End If
    End Sub
    
    Private Sub ToggleButton51N_Click()
    If ToggleButton51N.Value = True Then
        Sheets("Input").Range("k71") = "No"
        ToggleButton51N.BackColor = RGB(255, 20, 3)
        ToggleButton51Y.Value = False
        ToggleButton51Y.BackColor = &H8000000F
        ToggleButton51NA.Value = False
        ToggleButton51NA.BackColor = &H8000000F
    
    End If
    End Sub
    
    Private Sub ToggleButton51NA_Click()
    If ToggleButton51NA.Value = True Then
        Sheets("Input").Range("k71") = "N/A"
        ToggleButton51NA.BackColor = RGB(145, 145, 145)
        ToggleButton51Y.Value = False
        ToggleButton51Y.BackColor = &H8000000F
        ToggleButton51N.Value = False
        ToggleButton51N.BackColor = &H8000000F
    
        
    End If
    End Sub
    Rather than repeat the code 50+ times, could someone point me in the right direction to be able to use the code once in a module (?) and then be able to call that module for each set of the 3 togglebuttons? It may be difficult as each answer is transferred into a non-consecutive cell in the workbook?

    Thank you in advance for any pointers.
    Last edited by poolierob; 09-12-2015 at 08:36 PM. Reason: additional info re frames

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ToggleButtons , lots of togglebuttons.. need to shorten the vba code
    By Aurbo in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-25-2015, 12:19 PM
  2. Replies: 2
    Last Post: 04-15-2013, 08:50 AM
  3. Code to rationalise multiple command buttons in VBA
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2012, 07:48 AM
  4. How to setup a graph from multiple data sets into a single display
    By pjw23 in forum Excel Charting & Pivots
    Replies: 9
    Last Post: 10-20-2012, 06:03 AM
  5. Replies: 1
    Last Post: 08-02-2012, 03:58 AM
  6. Converting Multiple sets of rows to a single row
    By JuJuBe in forum Excel General
    Replies: 4
    Last Post: 05-11-2012, 10:56 AM
  7. Togglebuttons as drawers on multiple sheets
    By Claus in forum Excel General
    Replies: 0
    Last Post: 07-05-2005, 03:05 AM

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