close

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: www.excelforum.com/member.php...oamp;userid=20336
View this thread: www.excelforum.com/showthread...hreadid=531555If that's in C21, you could just pick up the results of the formula:

Option Explicit
Private Sub UserForm_Initialize()
Me.TextBox1.Value =
Worksheets(quot;sheet1quot;).Range(quot;C21quot;).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(quot;sheet1quot;).Range(quot;A2 1quot;).Value, _
Worksheets(quot;Sheet3quot;).Range(quot;A2:L17quot;), _
Worksheets(quot;sheet1quot;).Range(quot;A1quot;).Value, _
False)

If IsError(res) Then
myStr = quot;Missing/no match!quot;
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:
gt;
gt; I have the following code in cell C21 of my spreadsheet.
gt; =VLOOKUP(A21,Sheet3!$A$2:$L$17,$A$1,FALSE)
gt;
gt; How do I put the equivelant in TextBox1 of my UserForm??
gt;
gt; --
gt; grahammal
gt; ------------------------------------------------------------------------
gt; grahammal's Profile: www.excelforum.com/member.php...oamp;userid=20336
gt; View this thread: www.excelforum.com/showthread...hreadid=531555

--

Dave Peterson

arrow
arrow
    全站熱搜

    software 發表在 痞客邦 留言(0) 人氣()