Consulting

Results 1 to 8 of 8

Thread: Solved: Populate UserForm TextBox based on Worksheet Lookup

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location

    Solved: Populate UserForm TextBox based on Worksheet Lookup

    Hello gurus

    I have a worksheet with Jobtitles in column A and there relevant competencies in columns B to Z for each Jobtitle.

    I have a UserForm with a Job Title TextBox and a MultiPage Control with pages 1 to 25. On each MultiPage page I have a TextBox which I want to populate with the relevant competency.

    i.e
    MultiPage1.TextBox1.Value=lookup jobtitle and return column B content;
    MultiPage2.TextBox2.Value=lookup jobtitle and return column C content;
    etc...

    Any suggestions
    Kindest Regards,
    Mike

    I love to Excel

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub TextBox1_AfterUpdate()
    Dim iRow As Long
    With Me
    On Error Resume Next
    iRow = Application.Match(.TextBox1.Text, Worksheets("Sheet1").Columns(1), 0)
    On Error GoTo 0
    If iRow > 0 Then
    .MultiPage1.Pages(1).TextBox2.Text = Worksheets("Sheet1").Cells(iRow, "B").Value
    End If
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location
    Hello Mr.X

    I used the following code

    [VBA]
    Private Sub TextBox2_AfterUpdate()
    Dim iRow As Long
    With Me
    On Error Resume Next
    iRow = Application.Match(.TextBox1.Text, Worksheets("Competencies").Columns(1), 0)
    On Error GoTo 0
    If iRow > 0 Then
    .MultiPage1.Pages(2).TextBox2.Text = Worksheets("Competencies").Cells(iRow, "B").Value
    End If
    End With
    End Sub
    [/VBA]

    The TextBox is still not populating??
    Kindest Regards,
    Mike

    I love to Excel

  4. #4
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location
    Sorry Mr.X,

    I meant

    [VBA]
    Private Sub TextBox2_AfterUpdate()
    [/VBA]

    Nothing is being returned ??
    Kindest Regards,
    Mike

    I love to Excel

  5. #5
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location


    [VBA]
    Private Sub TextBox1_AfterUpdate()
    [/VBA]
    Kindest Regards,
    Mike

    I love to Excel

  6. #6
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location
    Still not populating......

    Additionally, if I type in other text I receive an error type 439

    "Object not supported by this method or property"

    Can anyone help out on this
    Kindest Regards,
    Mike

    I love to Excel

  7. #7
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You should just be able to use:
    [VBA]Me.TextBox2.Text = Worksheets("Competencies").Cells(iRow, "B").Value [/VBA]

    Regards,
    Rory

  8. #8
    VBAX Regular
    Joined
    May 2007
    Posts
    81
    Location
    Thanks Rory,

    I'll use your streamlined version...............

    but.. I am a drongo

    Forgot 1st page of multipage = 0


    Thanks Mr.X
    Kindest Regards,
    Mike

    I love to Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •