Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select Row in List Box with 2 columns - Col 1 populates form 1 box1,Col 2 pop box2

Hi my first post. great resource.

This is my first real VB project. Please dont laugh at my code. Im a
newbie. :)


The part I cant figure out is this:

These are the relevant objects:
Form 1 (ufCombIns) has a commandbutton1 - click this and it opens Form
2
Form 1 has textbox(tbxOcCat) and a combobox (cbxOcCat) (among many
other things)

Form 2 (ufOcCat) has a list box (lbxOcCat) with 2 columns!!!
This contains a 2 column range from a worksheet(OcCat!).

The user selects (double clicks) the relevent row in lbxOcCat....
and this is the part Im having difficulty with....

The info in ufOcCat column1 should go to ufCombIns, tbxOcCat
and ufOcCat column2 goes to ufCombIns, cbxOcCat
and ufOcCat is closed.

This is what I have so far......
(Some of this relates to the search function for lbxOcCat - just ignore
cause that bit works...)

Private Sub cmdLookUp_Click()
Unload Me
End Sub

Private Sub TextBox1_Change()

Dim s As String
Dim i As Integer
s = TextBox1.Text

lbxOcCat.ListIndex = -1
If TextBox1.Text = "" Then
Exit Sub
End If
For i = 0 To lbxOcCat.ListCount - 1
If UCase(lbxOcCat.List(i)) Like UCase(s & "*") Then
lbxOcCat.ListIndex = i
Exit Sub
End If
Next

End Sub

Private Sub UserForm_Initialize()
lbxOcCat.RowSource = "OcCat!A2:B895"

End Sub

Private Sub lbxOcCat_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If lbxOcCat.ListIndex = -1 Then
Exit Sub
End If
Selection.Cells(1) = 'ufCombIns.tbxOcCat
Selection.Cells(1).Offset(0, 1) = 'ufCombIns.cbxOcCat
Unload Me
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select Row in List Box with 2 columns - Col 1 populates form 1 box1,Col 2 pop box2

Private Sub lbxOcCat_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If lbxOcCat.ListIndex = -1 Then
Exit Sub
End If
With me.lbxOcCat
ufCombIns. tbxOcCat.Value = .List(.ListIndex,0)
ufCombIns.cbxOcCat.Value = .List(.listIndex,1)
End With
Unload Me
End Sub

--
Regards,
Tom Ogilvy


wrote in message
ups.com...
Hi my first post. great resource.

This is my first real VB project. Please dont laugh at my code. Im a
newbie. :)


The part I cant figure out is this:

These are the relevant objects:
Form 1 (ufCombIns) has a commandbutton1 - click this and it opens Form
2
Form 1 has textbox(tbxOcCat) and a combobox (cbxOcCat) (among many
other things)

Form 2 (ufOcCat) has a list box (lbxOcCat) with 2 columns!!!
This contains a 2 column range from a worksheet(OcCat!).

The user selects (double clicks) the relevent row in lbxOcCat....
and this is the part Im having difficulty with....

The info in ufOcCat column1 should go to ufCombIns, tbxOcCat
and ufOcCat column2 goes to ufCombIns, cbxOcCat
and ufOcCat is closed.

This is what I have so far......
(Some of this relates to the search function for lbxOcCat - just ignore
cause that bit works...)

Private Sub cmdLookUp_Click()
Unload Me
End Sub

Private Sub TextBox1_Change()

Dim s As String
Dim i As Integer
s = TextBox1.Text

lbxOcCat.ListIndex = -1
If TextBox1.Text = "" Then
Exit Sub
End If
For i = 0 To lbxOcCat.ListCount - 1
If UCase(lbxOcCat.List(i)) Like UCase(s & "*") Then
lbxOcCat.ListIndex = i
Exit Sub
End If
Next

End Sub

Private Sub UserForm_Initialize()
lbxOcCat.RowSource = "OcCat!A2:B895"

End Sub

Private Sub lbxOcCat_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If lbxOcCat.ListIndex = -1 Then
Exit Sub
End If
Selection.Cells(1) = 'ufCombIns.tbxOcCat
Selection.Cells(1).Offset(0, 1) = 'ufCombIns.cbxOcCat
Unload Me
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Select Row in List Box with 2 columns - Col 1 populates form 1 box1,Col 2 pop box2

Your a legend Tom.
And a prolific problem solver. Thanks heaps.

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
drop down list populates data in another cell Amanda H Excel Discussion (Misc queries) 4 December 31st 08 07:28 PM
Creating a Fill In form that populates a table Embyr42 Excel Discussion (Misc queries) 1 March 24th 08 06:22 PM
Dropdown List that populates another column HAZBONES Excel Worksheet Functions 7 December 1st 07 03:10 AM
How do you get outlook to select from list on a form gbpg Excel Discussion (Misc queries) 1 August 27th 07 05:54 PM
Select a category from a list that populates related cells Jules73 Excel Worksheet Functions 1 March 21st 07 07:28 PM


All times are GMT +1. The time now is 06:43 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"