• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Guide Line Required For Code in Excel vba combobox.

I have an excel sheet name "Data" .This Excel sheet having the following opjects.



1. User Form name "utBilsForm"

2.A multipage whith a first page name page1.

3.One Cobobox name combobox10 and two textboxes name textbox27 and textbox28.

4 One submit button.



I have data on three columns J,K and L.The data starts from column J9 , K9 and L9.I have already populated the combobox with the item on J column.



Now i want that when an item is selected from the combobox , the two textboxes fill with the data starts from K9 and L9 accordingly.



I have write the following code in combobox click event, but it is not working.Please guide me .

Code:
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets(“Data”)
LastRow = ws.Range(“J” & Rows.Count).End(xlUp).Row

For i = 9 To LastRow

Me.TextBox27 = ws.Cells(i, “K”).Value
Me.TextBox28 = ws.Cells(i, “L”).Value
Next i

Thanks
 
It depends on how you fill your combobox. Two methods:
1. Use ComboBox1.ListIndex plus row offset as your i without the For loop.
2. Use a range Find to find the cell in the combobox's range to find the cell and therefore the Row.
 
Back
Top