Pulling rows from worksheet into userform

llan_man

New Member
Joined
Nov 6, 2005
Messages
45
Hi,

I'm hoping someone can help me here. What I have is the following:

A spreadsheet with 20 columns
The fourth column contains an identifier relating to a particular "section"
There are many rows relating with the same identifier
I have a user form which has a combobox so the user can select a predefined identifier.
When the user selects this identifier, I want to recover all rows in my worksheet which have the same identifier in th fourt column,
Ideally I would like all columns to appear in one textbox separated by some form of split bar and a scroll bar. These must also be totalled at the bottom.

Anyone have any ideas on how I should get started as I'm struggling.

Thanks

Harv
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Code:
Private Sub ComboBox1_Change()
TextBox1.Text = ""

Dim cell As Range

For Each cell In Range(Range("d1"), Range("d65536").End(xlUp))
    If cell.Value = ComboBox1.Text Then
        TextBox1.Text = TextBox1.Text & cell.Offset(0, 1).Value & vbCrLf
    End If
Next cell



End Sub

Something like this will pull in the column right next to it with the offset command. I do not know if you have column 4 populated in each row or not but this should get you going in the right direction. The vbcrlf is to go down a line and in my textbox, I have it set to multiline = true.
 
Upvote 0
Anthony

Thanks very much. That's extremely useful code. Would you know how to display the data in columns within the same textbox?

Thanks

Harv
 
Upvote 0
You would probably be better with a listbox.

With Listbox, change the code:
Code:
TextBox1.Text = TextBox1.Text & cell.Offset(0, 1).Value & vbCrLf

To this:
Code:
listbox.add cell.offset(0,1).value
 
Upvote 0

Forum statistics

Threads
1,226,497
Messages
6,191,372
Members
453,655
Latest member
lasvegasbuffet

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