Populating textboxes from combobox with data from another workbook

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
93
Hi, I am needing to populate some textboxes with a combobox from another workbook I can populate the combobox but can not work out how to populate the textboxes using a Sub ComboBox_Change change can anyone help.

Private Sub UserForm_Initialize()
Dim wbExternal As Workbook
Dim wsExternal As Worksheet
Dim lngLastRow As Long
Dim rngExternal As Range
Set wbExternal = Application.Workbooks("PriceSheet.xls")
Set wsExternal = wbExternal.Worksheets("ALL")
lngLastRow = wsExternal.Range("Q" & wsExternal.Rows.Count).End(xlUp).Row
Set rngExternal = wsExternal.Range("A3:A" & CStr(lngLastRow))
ComboBox1.RowSource = rngExternal.Address(External:=True)
End Sub


Regards
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
93
I managed to figure it out :biggrin:

Private Sub UserForm_Initialize()
Dim wbExternal As Workbook
Dim wsExternal As Worksheet
Dim lngLastRow As Long
Dim rngExternal As Range
Set wbExternal = Application.Workbooks("PriceSheet.xls")
Set wsExternal = wbExternal.Worksheets("ALL")
lngLastRow = wsExternal.Range("Q" & wsExternal.Rows.Count).End(xlUp).Row
Set rngExternal = wsExternal.Range("A3:A" & CStr(lngLastRow))
ComboBox1.RowSource = rngExternal.Address(External:=True)
End Sub

Private Sub ComboBox1_Change()
Me.TextBox1.Text = Workbooks("PriceSheet.xls").Worksheets("ALL").Range("B" & Me.ComboBox1.ListIndex + 3).Value
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,100,028
Messages
5,472,089
Members
406,800
Latest member
TeachMeExcelPlease

This Week's Hot Topics

Top