Populating Text Boxes from a ComboBox on a Userform

Terry P

Active Member
Joined
Nov 28, 2002
Messages
256
I have 10 columns of 4 rows of data eg:
Fund names > Comm Corp. etc
Carried Forward > 1000 2500 etc
Transferred in > 500 600 etc
Transferred out > 100 50 etc
Balance > 1400 3050 etc

On a userform I have a ComboBox which shows the Fund names of Comm, Corp,etc.
When, say, the Comm name is chosen I would like to have 4 Text Boxes on the form showing the relevant figures ie 1000-500-100-1400.
I’d be very grateful for any ideas.
Thanks
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Terry,
I'm not clear on your layout, but maybe you can adapt this to something that'll help.

Assuming your combobox data is in column A, and you want textbox1 to return what's in column B of the combobox choice, textbox2 to return column C, textbox3, to return column D, (etc.) then here's some code you can try for the combobox.
Code:
Private Sub ComboBox1_Change()
Dim i As Long
i = [A65536].End(xlUp).Row
For x = 1 To i
If Cells(x, 1).Value = ComboBox1.Value Then
    TextBox1.Value = Cells(x, 1)(1, 2).Value
    TextBox2.Value = Cells(x, 1)(1, 3).Value
    TextBox3.Value = Cells(x, 1)(1, 4).Value
    TextBox4.Value = Cells(x, 1)(1, 5).Value
End If
Next x
End Sub
If this is completely off base then post back with a more detailed description of your layout and desired results.

Hope it helps,
Dan
 
Upvote 0
Dan
Many thanks for such a quick reply.
I'll give your suggestion a try and will come back with either thanks or need more help as offered.
Terry
 
Upvote 0
Hi Dan
I have just one 'small' problem.
That is, the sheet I'm looking up is a different one to the one that the userform is used on. The sheet is named Finance (2)
and I cannot seem to grasp the sintax. :oops:
Private Sub ComboBox1_Change()
Dim i As Long
i = [a65536].End(xlUp).Row
For x = 1 To i
If Cells(x, 1).Value = ComboBox1.Value Then
TextBox7.Value = Cells(x, 1)(1, 2).Value
TextBox8.Value = Cells(x, 1)(1, 3).Value
TextBox9.Value = Cells(x, 1)(1, 4).Value
TextBox10.Value = Cells(x, 1)(1, 5).Value
End If
Next x
End Sub
 
Upvote 0
Dan
Thanks for your help I've cracked it. Embarrasingly simple really.
I used the screenupdating = false/true and it's just great.
 
Upvote 0

Forum statistics

Threads
1,215,745
Messages
6,126,626
Members
449,323
Latest member
Smarti1

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