+ Reply to Thread
Results 1 to 2 of 2

Populating check box values from a list on another sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2014
    Location
    Hyde, Manchester
    MS-Off Ver
    2010
    Posts
    79

    Populating check box values from a list on another sheet

    Hi guys I've been scouring the internet for a solution to this problem but I can't seem to find it anywhere.

    Basically I'm creating a worksheet which is going to be a generic sheet to fit all of the work that we do, in order to do this I have a userform with a series of checkboxes on it to generate pages and show specific data on those pages for what is and isn't selected from these checkboxes.

    The following code takes all of the data from my checkboxes and stores their values onto a worksheet:

    Dim contr As Control
        Dim x As Integer
    
        x = 3
            For Each contr In rollercoastersetup.Controls
                If TypeName(contr) = "CheckBox" Then
                    Sheets("ChkBox Results").Cells(x, "B").Value = contr.Name
                    Sheets("ChkBox Results").Cells(x, "C").Value = contr.Value
                    x = x + 1
                End If
                
                If TypeName(contr) = "TextBox" Then
                    Sheets("ChkBox Results").Cells(x, "B").Value = contr.Name
                    Sheets("ChkBox Results").Cells(x, "C").Value = contr.Value
                    x = x + 1
                End If
            Next
    This code generates the list of all the controls on the userform in one column (starting from B3) and all the values of those controls in the next column (starting at C3) as below:

    Check Box Name True/False/Value
    oproomnopanel TRUE
    oproomwithpanel FALSE
    station FALSE

    What I'd like to be able to do with that info is to then be able to repopulate the userform when it is re opened so that if somebody needs to add or remove something it can be done in this way rather than restarting the whole worksheet. The code I have is as follows but the syntax isn't even close to being right so any help would be greatly appreciated!

    Private Sub UserForm_Activate()
    
        Dim controlname As Integer
    
            For controlname = 3 To 200
                Me.Controls(Sheets("ChkBox Results").Cells(controlname, "B").Value).Value = Sheets("ChkBox Results").Cells(controlname, "C").Value
            Next
    
    End Sub
    Thanks for your help

    Tom

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Populating check box values from a list on another sheet

    I would do it this way.
    Private Sub UserForm_Initialize()
    
    Dim controlname As Integer
    Dim aCell As Range
    
        For controlname = 3 To 200
            Set aCell = Sheets("ChkBox Results").Cells(controlname, "B")
            Me.Controls(aCell.Value).Value = aCell.Offset(0, 1).Value
        Next
    End Sub
    David
    (*) Reputation points appreciated.

+ 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] Populating List based on a Value chosen from another List of Values
    By Vinod Krishna.C in forum Excel General
    Replies: 3
    Last Post: 02-03-2014, 07:26 AM
  2. Replies: 1
    Last Post: 12-14-2012, 01:56 PM
  3. Populating a list using selected values in a column
    By Panlid in forum Excel General
    Replies: 3
    Last Post: 10-18-2010, 10:55 AM
  4. Populating a report sheet based on imported values on another sheet
    By th3spankst3r in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-05-2010, 06:19 PM
  5. populating list with unique values (revised)
    By jchambers00 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-25-2007, 01:19 PM
  6. Populating Unique Values into new List
    By jchambers00 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-25-2007, 10:48 AM
  7. populating a list from another sheet
    By chrysti in forum Excel General
    Replies: 4
    Last Post: 12-20-2006, 04:38 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