Userform coding

0

Hi,

I have some questions, I have 1combo box loaded with all item list. 1text box  and 1button.

How to code if this selected item from combo box will find the specific item list in a sheet once found the text box data enter to the columns where this selected specific item found when i hit the button to enter the data.

Pleased help on this...thanks a lot.

Answer
Discuss

Discussion

Normally, one would know where the data in the combo box came from. Therefore there should be no need to search for them all over again. So, I suggest that you split your question into two. One how to load the combobox and two how to write the textbox entry to the worksheet. If we want to do part one in this question, tell us where you get the list for the combo box. Of course, this is reverse of the question how do the items in the combo box relate to things on your worksheet.
Variatus (rep: 813) Aug 15, '17 at 2:37 am
this combo box drop down list have all the list of items from my sheet 1 then in my sheet 2 colunm A, I have the same list of Item, sheet 2 colunm B where I want to put my  text box data entry once found from cmbo box selected the item from drop down list  the data will go to the sheet 2 colunm b  
Glenlapz Aug 15, '17 at 6:02 am
Why are you fillling the combobox from sheet 1 if the list is in Sheet 2? If Sheet two has multiple occurrences of the same item, how to know which one you want? And if sheet 2 has each item only once you already know in which row each item is.
Variatus (rep: 813) Aug 15, '17 at 6:26 am
Variatus...
Thank u for your time..tnx a lot..
I think we have different understanding.and i can't explained u well what i want..maybe i can find it my own..
Glenlapz Aug 15, '17 at 6:36 am
I understand that. How do you load the items from sheet 1 into the combo box? Please post your code for this action.
Variatus (rep: 813) Aug 16, '17 at 7:12 am
Add to Discussion

Answers

0

Once you get the value from the combo box, you can loop through the columns that have the data for which youa re searching like this:

Sub test()

'get the range through which we want to loop

Set cell_range = Range("A1:A10")


'start the loop

For Each cell In cell_range

    'you are now inside the loop

    If cell.Value = comboboxValue Then

        Cells(cell.Row, cell.Column + 1).Value = textboxValue

    End If


'continue the loop

Next cell

End Sub

A1:A10 is the range to go through to find the value.

comboboxValue should contain the value from the combobox.

textboxValue should contains the text box value.

cell.Column + 1 is how many columns to the right of the column that you just searched through to put the value. +1 means 1 column to the right; +2 means 2 columns t othe right, etc.

This is the framework of the macro that you will need and it should get you almost all the way there; just make sure this runs when the command button is clicked.

Discuss

Answer the Question

You must create an account to use the forum. Create an Account or Login