Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
List Values to TextBox
Have a UserForm with a number of TextBoxes. When I click on TextBox1 it
opens a new Userform which displays a ListBox What I need to know is when I close the ListBox Userform, how do I get the selected values (which are in Column 1,5 and 6) into TextBox 1, 2 and 3. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
List Values to TextBox
I used this code to show the second userform2:
Me.Hide UserForm2.Show Me.Show Then I used this code behind UserForm2: Option Explicit Private Sub CommandButton1_Click() With Me.ListBox1 If .ListIndex < 0 Then 'nothing selected, same as cancel? Else UserForm1.TextBox1.Value = .List(.ListIndex, 0) UserForm1.TextBox2.Value = .List(.ListIndex, 1) UserForm1.TextBox3.Value = .List(.ListIndex, 2) End If End With Unload Me End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub UserForm_Initialize() Dim myRng As Range With Worksheets("sheet1") Set myRng = .Range("a1:G5") End With With Me.ListBox1 .List = myRng.Value .ColumnCount = myRng.Columns.Count .MultiSelect = fmMultiSelectSingle End With With Me.CommandButton1 .Default = True .Caption = "Ok" End With With Me.CommandButton2 .Cancel = True .Caption = "Cancel" End With End Sub "Patrick C. Simonds" wrote: Have a UserForm with a number of TextBoxes. When I click on TextBox1 it opens a new Userform which displays a ListBox What I need to know is when I close the ListBox Userform, how do I get the selected values (which are in Column 1,5 and 6) into TextBox 1, 2 and 3. -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
List Values to TextBox
Thank you,
Any way those ListValues could be formated as 00:00? "Dave Peterson" wrote in message ... I used this code to show the second userform2: Me.Hide UserForm2.Show Me.Show Then I used this code behind UserForm2: Option Explicit Private Sub CommandButton1_Click() With Me.ListBox1 If .ListIndex < 0 Then 'nothing selected, same as cancel? Else UserForm1.TextBox1.Value = .List(.ListIndex, 0) UserForm1.TextBox2.Value = .List(.ListIndex, 1) UserForm1.TextBox3.Value = .List(.ListIndex, 2) End If End With Unload Me End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub UserForm_Initialize() Dim myRng As Range With Worksheets("sheet1") Set myRng = .Range("a1:G5") End With With Me.ListBox1 .List = myRng.Value .ColumnCount = myRng.Columns.Count .MultiSelect = fmMultiSelectSingle End With With Me.CommandButton1 .Default = True .Caption = "Ok" End With With Me.CommandButton2 .Cancel = True .Caption = "Cancel" End With End Sub "Patrick C. Simonds" wrote: Have a UserForm with a number of TextBoxes. When I click on TextBox1 it opens a new Userform which displays a ListBox What I need to know is when I close the ListBox Userform, how do I get the selected values (which are in Column 1,5 and 6) into TextBox 1, 2 and 3. -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
List Values to TextBox
In the textboxes?
if isnumeric(.list(.listindex,0) then UserForm1.TextBox1.Value = format(.List(.ListIndex, 0), "00:00") end if (or "hh:mm" or "mm:ss"????) "Patrick C. Simonds" wrote: Thank you, Any way those ListValues could be formated as 00:00? "Dave Peterson" wrote in message ... I used this code to show the second userform2: Me.Hide UserForm2.Show Me.Show Then I used this code behind UserForm2: Option Explicit Private Sub CommandButton1_Click() With Me.ListBox1 If .ListIndex < 0 Then 'nothing selected, same as cancel? Else UserForm1.TextBox1.Value = .List(.ListIndex, 0) UserForm1.TextBox2.Value = .List(.ListIndex, 1) UserForm1.TextBox3.Value = .List(.ListIndex, 2) End If End With Unload Me End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub UserForm_Initialize() Dim myRng As Range With Worksheets("sheet1") Set myRng = .Range("a1:G5") End With With Me.ListBox1 .List = myRng.Value .ColumnCount = myRng.Columns.Count .MultiSelect = fmMultiSelectSingle End With With Me.CommandButton1 .Default = True .Caption = "Ok" End With With Me.CommandButton2 .Cancel = True .Caption = "Cancel" End With End Sub "Patrick C. Simonds" wrote: Have a UserForm with a number of TextBoxes. When I click on TextBox1 it opens a new Userform which displays a ListBox What I need to know is when I close the ListBox Userform, how do I get the selected values (which are in Column 1,5 and 6) into TextBox 1, 2 and 3. -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
TextBox Values | Excel Programming | |||
Textbox values | Excel Programming | |||
How do I add TextBox.values? | Excel Programming | |||
How do I add TextBox.values? | Excel Discussion (Misc queries) | |||
How do I add TextBox.values? | Excel Worksheet Functions |