expand selection based on cell value

Sanibel

New Member
Joined
Mar 26, 2010
Messages
3
Hi, I have data sorted by column A, which are employee names. There are many line items for each employee name. I need to parse out the data by employee name - I would like to select all of the rows for one employee and cut and paste the data into another workbook. I can create a new workbook but am having difficulty defining the selection for each cut.

Can someone help me in defining the selection for each cut? I don't have much right now:

Dim Associate As String
Dim MyCell As Range

Do While Range("A2") <> ""
Range("A1").End(xlDown).Select
Associate = Selection.Text
For Each MyCell In Selection
If MyCell.Value = Associate Then


Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Filtering column A on the employee name would be the easiest way of gathering all of that employee's rows.
 
Upvote 0
Thanks for the suggestion Mike, but I actually need this to be done automatically so various users can do this without having to go through all the motions or know excel really well.
I could really use some help in looping through a definition for each selection.
 
Upvote 0
I'm suggesting using AutoFilter in your macro rather than a loop.
Record a macro of you doing what would be needed to do "Bob"'s records using AutoFilter and copy/paste with the last step being the turning of AutoFilter off.

Then that recorded macro can be modified to accept user input (from and InputBox? from a sheet's cell?) rather than the hard coded "Bob".
 
Upvote 0
Ah, ok, thank you! The issue is, I need to be able to parse out the data for each employee, (a file will be created for eah employee with that employee's data) and this is a dynamic data set. So am still not sure if a filter would work in this case. Would you agree? Sorry for any confusion!
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

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