![]() |
using a list box to fill text boxes
Hi,
I have a form with 2 combo boxes and 1 list box that I would like to use to automatically fill in numerous text boxes. The first combo box is the sheet (and stored in variable myUnit for other uses) and the second is the column (stored in myColumn also) and these generate the list box. When someone clicks on an item in the list box I need to get more information from that row and show them in the text boxes on the other side. I am new at this and nothing seems to be working and appreciate your help. |
using a list box to fill text boxes
I'm not quite sure how you've got your data setup but this should get you the
general idea. Private Sub ListBox1_Click Dim SelectCell As Range Const oSet As Long = 0 'Offset that determines how what row to start on Set SelectCell = Cells(ListBox1.ListIndex + oSet, myColumn) TextBox1.Text = SelectCell TextBox2.Text = SelectCell.Offset(,1) 'Cell to the right of SelectCell TextBox3.Text = SelectCell.Offset(,-1) 'Cell to the left of SelectCell End Sub Post back if you need more help -- Charles Chickering "A good example is twice the value of good advice." "Jim T." wrote: Hi, I have a form with 2 combo boxes and 1 list box that I would like to use to automatically fill in numerous text boxes. The first combo box is the sheet (and stored in variable myUnit for other uses) and the second is the column (stored in myColumn also) and these generate the list box. When someone clicks on an item in the list box I need to get more information from that row and show them in the text boxes on the other side. I am new at this and nothing seems to be working and appreciate your help. |
using a list box to fill text boxes
Unfortunately I do not know what column they will be starting on as that is
the second combo box option. Once it is updated the list box then fills in with all the values in that column that are not null. I am also getting a run time error 13 €“ type mismatch message on the €śSet SelectCell€ť line. "Charles Chickering" wrote: I'm not quite sure how you've got your data setup but this should get you the general idea. Private Sub ListBox1_Click Dim SelectCell As Range Const oSet As Long = 0 'Offset that determines how what row to start on Set SelectCell = Cells(ListBox1.ListIndex + oSet, myColumn) TextBox1.Text = SelectCell TextBox2.Text = SelectCell.Offset(,1) 'Cell to the right of SelectCell TextBox3.Text = SelectCell.Offset(,-1) 'Cell to the left of SelectCell End Sub Post back if you need more help -- Charles Chickering "A good example is twice the value of good advice." "Jim T." wrote: Hi, I have a form with 2 combo boxes and 1 list box that I would like to use to automatically fill in numerous text boxes. The first combo box is the sheet (and stored in variable myUnit for other uses) and the second is the column (stored in myColumn also) and these generate the list box. When someone clicks on an item in the list box I need to get more information from that row and show them in the text boxes on the other side. I am new at this and nothing seems to be working and appreciate your help. |
using a list box to fill text boxes
Are all the listings unique? Are there any blank rows in the data?
-- Charles Chickering "A good example is twice the value of good advice." "Jim T." wrote: Unfortunately I do not know what column they will be starting on as that is the second combo box option. Once it is updated the list box then fills in with all the values in that column that are not null. I am also getting a run time error 13 €“ type mismatch message on the €śSet SelectCell€ť line. "Charles Chickering" wrote: I'm not quite sure how you've got your data setup but this should get you the general idea. Private Sub ListBox1_Click Dim SelectCell As Range Const oSet As Long = 0 'Offset that determines how what row to start on Set SelectCell = Cells(ListBox1.ListIndex + oSet, myColumn) TextBox1.Text = SelectCell TextBox2.Text = SelectCell.Offset(,1) 'Cell to the right of SelectCell TextBox3.Text = SelectCell.Offset(,-1) 'Cell to the left of SelectCell End Sub Post back if you need more help -- Charles Chickering "A good example is twice the value of good advice." "Jim T." wrote: Hi, I have a form with 2 combo boxes and 1 list box that I would like to use to automatically fill in numerous text boxes. The first combo box is the sheet (and stored in variable myUnit for other uses) and the second is the column (stored in myColumn also) and these generate the list box. When someone clicks on an item in the list box I need to get more information from that row and show them in the text boxes on the other side. I am new at this and nothing seems to be working and appreciate your help. |
All times are GMT +1. The time now is 02:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com