Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
drop down list populates data in another cell | Excel Discussion (Misc queries) | |||
Creating a Fill In form that populates a table | Excel Discussion (Misc queries) | |||
Dropdown List that populates another column | Excel Worksheet Functions | |||
How do you get outlook to select from list on a form | Excel Discussion (Misc queries) | |||
Select a category from a list that populates related cells | Excel Worksheet Functions |