Populating textboxes from combobox with data from another workbook

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
172
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
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,710
Members
448,293
Latest member
jin kazuya

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