List Breakdown

Dishboy09

New Member
Joined
Jun 11, 2017
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I have a list of names from the 5 teams in my division in alphabetical order. I would like to have a macro that pulls just my teams names and info from the list and places it onto a separate sheet for easy reading.

How would i set this up?

Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
adjust cell locations as needed

Code:
Sub aScanTeamList()
Dim vTeam, vPlayer
Dim colTeams As New Collection
Dim colPlayers As New Collection
Dim itm
Dim i As Integer

On Error GoTo ErrScan

Sheets("sheet1").Select
Range("A2").Select
While ActiveCell.Value <> ""
      vTeam = ActiveCell.Offset(0, 0).Value
    vPlayer = ActiveCell.Offset(0, 1).Value
        
    colTeams.Add vTeam, vTeam
    colPlayers.Add vTeam & ":" & vPlayer
    
     ActiveCell.Offset(1, 0).Select    'next row
Wend


  'create the sheet
For Each itm In colTeams
   Sheets.Add
   ActiveSheet.Name = itm
Next


  'post the teams
For Each itm In colPlayers
   i = InStr(itm, ":")
   vTeam = Left(itm, i - 1)
   vPlayer = Mid(itm, i + 1)
   Sheets(vTeam).Select
   ActiveCell.Offset(0, 0).Value = vPlayer
   ActiveCell.Offset(0, 1).Value = vTeam
   ActiveCell.Offset(1, 0).Select    'next row
Next


Exit Sub
ErrScan:
If Err = 457 Or Err = 1004 Then Resume Next  'already in collection or (sheet exists 1004)
MsgBox Err.Description, , Err
End Sub
 
Last edited:
Upvote 0
Please excuse my ignorance in this matter, but where in the code do you set the name of the members to move?


adjust cell locations as needed

Code:
Sub aScanTeamList()
Dim vTeam, vPlayer
Dim colTeams As New Collection
Dim colPlayers As New Collection
Dim itm
Dim i As Integer

On Error GoTo ErrScan

Sheets("sheet1").Select
Range("A2").Select
While ActiveCell.Value <> ""
      vTeam = ActiveCell.Offset(0, 0).Value
    vPlayer = ActiveCell.Offset(0, 1).Value
        
    colTeams.Add vTeam, vTeam
    colPlayers.Add vTeam & ":" & vPlayer
    
     ActiveCell.Offset(1, 0).Select    'next row
Wend


  'create the sheet
For Each itm In colTeams
   Sheets.Add
   ActiveSheet.Name = itm
Next


  'post the teams
For Each itm In colPlayers
   i = InStr(itm, ":")
   vTeam = Left(itm, i - 1)
   vPlayer = Mid(itm, i + 1)
   Sheets(vTeam).Select
   ActiveCell.Offset(0, 0).Value = vPlayer
   ActiveCell.Offset(0, 1).Value = vTeam
   ActiveCell.Offset(1, 0).Select    'next row
Next


Exit Sub
ErrScan:
If Err = 457 Or Err = 1004 Then Resume Next  'already in collection or (sheet exists 1004)
MsgBox Err.Description, , Err
End Sub
 
Upvote 0
Have you looked at AdvancedFilter and its copy to other location feature?
Or you could just use Autofilter to show just your team's and then copy/paste
 
Upvote 0
in my example,
Team is in Col.A
player is in Col.B

vPlayer = ActiveCell.Offset(0, 1).Value
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,028
Members
452,542
Latest member
Bricklin

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