View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
tkraju via OfficeKB.com tkraju via OfficeKB.com is offline
external usenet poster
 
Posts: 109
Default fetch a value from a w/sheet to userform.

Thank you ,Slarbie,I got what I need, can you explain me the code,line by
line.

slarbie wrote:
with just your combobox you could accomplish what you're describing. Set the
combobox columncount property to 2, then use the following code for the form.
Vlookup isn't needed at all this way. The combobox shows what's in the
second column, and can return that value anywhere you want to use it. But if
you absolutely had to have it in a textbox for some reason, this shows that
as well. You really don't need the "fetch" button.

Private Sub UserForm_Initialize()

Dim myList As String
Dim LastRow As Integer

LastRow = Range("a2").End(xlDown).Row
myList = Range(Cells(2, 1), Cells(LastRow, 2)).address
ComboBox1.RowSource = myList

End Sub

Private Sub ComboBox1_Change()

TextBox1 = ComboBox1.Column(1)

End Sub

I have a userform with a combobox 1,a text box 1and a command button(fetch)
I want sheet1! A2 to last used cell in Col A as combobox 1 values.
If a a value is selected from combox list ,and click fetch command button,
then vlookup that value from sheet1A2:F200,from column 5 fetch to textbox1.
what code I have to add to userform code module for above 2 tasks.
Thanks in advance to all Vba experts.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1