#1   Report Post  
Posted to microsoft.public.excel.misc
grahammal
 
Posts: n/a
Default 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??


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=531555

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 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("A2 1").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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract Data From Textbox SEA Excel Worksheet Functions 6 February 5th 09 08:21 PM
Textbox moves position when Printing? Rugdoody Excel Discussion (Misc queries) 1 September 21st 05 09:42 PM
Legnth of text in textbox control rgarber50 Excel Discussion (Misc queries) 3 July 15th 05 02:18 PM
textbox scrollbar disappears Yaniv Excel Discussion (Misc queries) 1 June 20th 05 11:31 PM
manipulating textbox in chart Peter Hafner Charts and Charting in Excel 0 January 31st 05 10:55 AM


All times are GMT +1. The time now is 09:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"