+ Reply to Thread
Results 1 to 2 of 2

TextBox

  1. #1
    Forum Contributor
    Join Date
    02-24-2005
    Posts
    154

    TextBox

    I have the following code in cell C21 of my spreadsheet.
    =VLOOKUP(A21,Sheet3!$A$2:$L$17,$A$1,FALSE)

    How do I put the equivelant in TextBox1 of my UserForm??

  2. #2
    Dave Peterson
    Guest

    Re: TextBox

    If that's in C21, you could just pick up the results of the formula:

    Option Explicit
    Private Sub UserForm_Initialize()
    Me.TextBox1.Value =
    Worksheets("sheet1").Range("C21").Text
    End Sub

    Or you could do the =vlookup() in code:
    Option Explicit
    Private Sub UserForm_Initialize()

    Dim res As Variant
    Dim myStr As String

    res = Application.VLookup(Worksheets("sheet1").Range("A21").Value, _
    Worksheets("Sheet3").Range("A2:L17"), _
    Worksheets("sheet1").Range("A1").Value, _
    False)

    If IsError(res) Then
    myStr = "Missing/no match!"
    Else
    myStr = res
    End If

    Me.TextBox1.Value = myStr

    End Sub

    (I'm not sure what the name of the worksheet that held c21 is.)

    grahammal wrote:
    >
    > I have the following code in cell C21 of my spreadsheet.
    > =VLOOKUP(A21,Sheet3!$A$2:$L$17,$A$1,FALSE)
    >
    > How do I put the equivelant in TextBox1 of my UserForm??
    >
    > --
    > grahammal
    > ------------------------------------------------------------------------
    > grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
    > View this thread: http://www.excelforum.com/showthread...hreadid=531555


    --

    Dave Peterson

+ 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