ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   2 lists - extract from one all matches, edit in a new list then re (https://www.excelbanter.com/excel-programming/381145-2-lists-extract-one-all-matches-edit-new-list-then-re.html)

colorado808

2 lists - extract from one all matches, edit in a new list then re
 
How do I cut a set of data lines from a worksheet of data and put them into
another worksheet, based upon a match of one field to a combo box.

i.e. select a name in a combo box

go to the detailed data worksheet

find all lines that match that name in a particular field

cut those lines from the detailed worksheet and put them in another worksheet.

The data worksheet will continually be changing in size...

Any suggestions?

JLGWhiz

2 lists - extract from one all matches, edit in a new list then re
 
I have to be honest and tell you that I don't work very much with comboboxes,
but this seemed to work OK when I tested it. Try it on a copy of your sheet
in a new wb first.

Sub cpyPstCmbo()

Dim ws1 As Worksheet, ws2 As Worksheet, cb As Variant
Set ws1 = Worksheets(1)
Set ws2 = Worksheets(2)
UserForm1.Show
Set cb = UserForm1.ComboBox1

lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lr
If Cells(i, 1) = cb.Value Then
Cells(i, 1).EntireRow.Copy
ws2.Activate
If Cells(1, 1) < "" Then
ws2.Cells(Cells(Rows.Count, 1).End(xlUp).Row + 1, 1).Activate
Else
ws2.Cells(1, 1).Activate
End If
ActiveSheet.Paste
ws1.Activate
End If
Next
Application.CutCopyMode = False
End Sub


"colorado808" wrote:

How do I cut a set of data lines from a worksheet of data and put them into
another worksheet, based upon a match of one field to a combo box.

i.e. select a name in a combo box

go to the detailed data worksheet

find all lines that match that name in a particular field

cut those lines from the detailed worksheet and put them in another worksheet.

The data worksheet will continually be changing in size...

Any suggestions?



All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com