Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
TextBox Values Abdul[_2_] Excel Programming 1 August 1st 06 11:35 AM
Textbox values browie Excel Programming 3 June 20th 05 02:52 PM
How do I add TextBox.values? WTG Excel Programming 4 February 28th 05 09:38 AM
How do I add TextBox.values? WTG Excel Discussion (Misc queries) 1 February 27th 05 08:25 PM
How do I add TextBox.values? WTG Excel Worksheet Functions 1 February 27th 05 08:22 PM


All times are GMT +1. The time now is 01:17 AM.

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"