+ Reply to Thread
Results 1 to 2 of 2

Taking information from worksheet and transferring it to Userform textboxes

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Ontario, Canada
    MS-Off Ver
    Office 2010
    Posts
    96

    Taking information from worksheet and transferring it to Userform textboxes

    Hi,

    I need a way (if at all possible) to take information in cells on my worksheet and transferring them into textboxes and checkboxes on a userform. I thought the below code would work for sure but it doesn't . To explain what i am doing - I have a table with information. There are lets say... "Colour" on the left side (Col A) and "Fruits" on the top rows. Each "Fruit" will have 3 columns of information relating to the fruit. I need to be able to choose a colour in a userform combobox, then choose any fruits that are that colour from a second combo box and have a button or a combobox_change event that runs and looks at the 3 pieces of information related to each "fruit" and transfers one piece of information to a textbox and another piece of information to a checkbox.

    Private Sub CommandButton2_Click()
    Dim UpdateRange As Range
    Dim rngRowFind As Range, rngColFind As Range
    
    Sheets("Detail").Activate
    
    
    Set rngRowFind = Range("A1:A50").Find(Combobox2.Value, LookIn:=xlValues)
    Set rngColFind = Range("G2:AJ2").Find(Combobox1.Value, LookIn:=xlValues)
    
    If Not rngRowFind Is Nothing And Not rngColFind Is Nothing Then
    
        ActiveCell = Cells(rngRowFind.Row, rngColFind.Column)
        Set UpdateRange = Range(ActiveCell, ActiveCell.Offset(0, 2))
        UpdateRange(1, 1).Select
        TextBox13.Value = UpdateRange(1, 2).Value
        
        If UpdateRange(1, 2).Text = "In Process" Then
        CheckBox23.Value = True
        ElseIf UpdateRange(1, 2).Text = "Complete" Then
        CheckBox22.Value = True
        ElseIf UpdateRange(1, 2).Text = "Planned" Then
        CheckBox24.Value = True
        End If
        
    End If
        
    
    End Sub
    Any help is appreciated

  2. #2
    Registered User
    Join Date
    02-21-2013
    Location
    Ontario, Canada
    MS-Off Ver
    Office 2010
    Posts
    96

    Re: Taking information from worksheet and transferring it to Userform textboxes

    Nvm got this working. Code:

    Private Sub Combobox2_Change()
    Dim LoadRange As Range
    Dim rngRowFind As Range, rngColFind As Range
    
    
    Set rngRowFind = Range("List1").Find(Combobox2.Value, LookIn:=xlValues)
    Set rngColFind = Range("List2").Find(Combobox1.Value, LookIn:=xlValues)
    
    'If Not rngRowFind Is Nothing And Not rngColFind Is Nothing Then
    
    Application.Goto Cells(rngRowFind.Row, rngColFind.Column)
    
    Set LoadRange = Range(Activecell, Activecell.Offset(0, 2))
    
    
        TextBox13.Value = LoadRange(1, 2).Value
    
        If LoadRange(1, 3).Text = "In Process" Then
        Me.CheckBox23.Value = True
        ElseIf LoadRange(1, 3).Text = "Complete" Then
        Me.CheckBox22.Value = True
        ElseIf LoadRange(1, 3).Text = "Planned" Then
        Me.CheckBox24.Value = True
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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