combo box list and text box displaying

VBAer

New Member
Joined
Jun 13, 2017
Messages
10
im kinda still new to VBA and need some help with the coding 0

i need to make a combo box that lists all items in column A where the user can add to the list (on excel sheet) and have it auto update. once the user selects an item, i want to have a text box show the data in the cell to the right of the item (cell) selected.

im just really new and not exactly how to set up the range with lastrow and xlup, as well as the offset (1,0) or offset (0,1)

thank you in advance for your help.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
i found the answer to my own question... here is the answer for anyone that might find this

Private Sub UserForm_Initialize()
Dim i As Long
Dim LastRow As Long
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Me.ComboBox1.AddItem ws.Cells(i, "A").Value
Next i
End Sub
Private Sub ComboBox1_Change()
Dim i As Long
Dim LastRow As Long
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.ComboBox1.Value) = ws.Cells(i, "A") Then
Me.TextBox1 = ws.Cells(i, "B").Value
End If
Next i


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top