Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
fetch a value from a w/sheet to userform.
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
fetch a value from a w/sheet to userform.
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 "tkraju via OfficeKB.com" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
fetch values from w/sheet | Excel Discussion (Misc queries) | |||
Using browser to login and fetch CSV | Excel Programming | |||
Fetch Autofilter options | Excel Programming | |||
Fetch Text From Website | Excel Programming | |||
Use 1 userform for many sheets, Rather than 1 userform per sheet: How? | Excel Programming |