Skrej
Board Regular
- Joined
- May 31, 2013
- Messages
- 176
- Office Version
- 365
- Platform
- Windows
Hi all
I'd like to create a macro that searches a column within a changing, variable range.
For example, I have a roster with a list of teams. Each team is separated by a blank row. In each team, there are a varying number of team members, and one team leader. Column I has the position code, which designates whether the person is the team leader (SL), or just a team member (RD).
What I'd like to do, is search each team for the team leader, then check another column (Col A) just within that team for another value, and if that value is present return the last name of the team leader as well as the name of the member with the value in Col A.
The problem is, I'm not sure how to search a varying range in Col I. Teams can vary in size from 3-11 members (including leader), and the number of teams varies each day. I don't have the option of changing the format or layout of the roster - it's automatically generated by some other program and given to me in a CSV list.
For example, from this sample data of two teams
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"]Testing Program : DKSFS
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"]Scoring Center : Concord
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD="width: 64"]Rater Schedule Date : 07/29/2013
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader : 3456 : Jones
[/TD]
[TD]Mark
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Emp. ID
[/TD]
[TD]Last name
[/TD]
[TD]First Name
[/TD]
[TD]Start time
[/TD]
[TD]Hours Sched
[/TD]
[TD]Shift code
[/TD]
[TD]work location
[/TD]
[TD]Position code
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]1234
[/TD]
[TD]Smith
[/TD]
[TD]John
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2345
[/TD]
[TD]Doe
[/TD]
[TD]Jane
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]3456
[/TD]
[TD]Jones
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]SL
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]4567
[/TD]
[TD]Rogers
[/TD]
[TD]Grant
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader Total : (Jones
[/TD]
[TD]Mark):4
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center Total : 4
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Testing Program : DKSFS
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center : Concord
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Rater Schedule Date : 07/29/2013
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader : 3456 : Pers
[/TD]
[TD]Matt
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2222
[/TD]
[TD]Smitts
[/TD]
[TD]Jon
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]3333
[/TD]
[TD]Grey
[/TD]
[TD]Luke
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4444
[/TD]
[TD]Pers
[/TD]
[TD]Matt
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]SL[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]5555
[/TD]
[TD]Mann
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]6666
[/TD]
[TD]Smith
[/TD]
[TD]Sue
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader Total : (Pers
[/TD]
[TD]Matt):5
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center Total : 5
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I'd like to return a list that starts at say K1 (arbitrary) that would give me this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]VM
[/TD]
[TD]1234
[/TD]
[TD]Smith
[/TD]
[TD]John
[/TD]
[TD]8:30
[/TD]
[TD]Jones
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]4567
[/TD]
[TD]Rogers
[/TD]
[TD]Grant
[/TD]
[TD]8:30
[/TD]
[TD]Jones
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]3333
[/TD]
[TD]Grey
[/TD]
[TD]Luke
[/TD]
[TD]8:30
[/TD]
[TD]Pers
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]6666
[/TD]
[TD]Mann
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]Pers
[/TD]
[/TR]
</tbody>[/TABLE]
What I'm stumped on is how to define that range in Col I which changes with each new team. My approach is to find a way to search a range (essentially the values between blank cells ) in Col I for the value "SL", then search that same range in Col A for the value "VM". If there's a value of VM within that range (team), then copy Cols A-E, write them to a list, and insert that person's team leader last name at the right.
Any suggestions for how to define a dynamic range in Col I? Or maybe suggestions on how to approach the problem in a different manner? I already have a working macro written which generates that last time, sans team leader name, just trying to figure out how to search that changing range in Col I for each team to find team leader name.
Note, not all teams will have a member flagged with that VM marker in Col A.
Thanks for suggestions.
I'd like to create a macro that searches a column within a changing, variable range.
For example, I have a roster with a list of teams. Each team is separated by a blank row. In each team, there are a varying number of team members, and one team leader. Column I has the position code, which designates whether the person is the team leader (SL), or just a team member (RD).
What I'd like to do, is search each team for the team leader, then check another column (Col A) just within that team for another value, and if that value is present return the last name of the team leader as well as the name of the member with the value in Col A.
The problem is, I'm not sure how to search a varying range in Col I. Teams can vary in size from 3-11 members (including leader), and the number of teams varies each day. I don't have the option of changing the format or layout of the roster - it's automatically generated by some other program and given to me in a CSV list.
For example, from this sample data of two teams
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"]Testing Program : DKSFS
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"]Scoring Center : Concord
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD="width: 64"]Rater Schedule Date : 07/29/2013
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader : 3456 : Jones
[/TD]
[TD]Mark
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Emp. ID
[/TD]
[TD]Last name
[/TD]
[TD]First Name
[/TD]
[TD]Start time
[/TD]
[TD]Hours Sched
[/TD]
[TD]Shift code
[/TD]
[TD]work location
[/TD]
[TD]Position code
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]1234
[/TD]
[TD]Smith
[/TD]
[TD]John
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2345
[/TD]
[TD]Doe
[/TD]
[TD]Jane
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]3456
[/TD]
[TD]Jones
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]SL
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]4567
[/TD]
[TD]Rogers
[/TD]
[TD]Grant
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader Total : (Jones
[/TD]
[TD]Mark):4
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center Total : 4
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Testing Program : DKSFS
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center : Concord
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Rater Schedule Date : 07/29/2013
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader : 3456 : Pers
[/TD]
[TD]Matt
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2222
[/TD]
[TD]Smitts
[/TD]
[TD]Jon
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]3333
[/TD]
[TD]Grey
[/TD]
[TD]Luke
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4444
[/TD]
[TD]Pers
[/TD]
[TD]Matt
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]SL[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]5555
[/TD]
[TD]Mann
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]6666
[/TD]
[TD]Smith
[/TD]
[TD]Sue
[/TD]
[TD]8:30
[/TD]
[TD]8.5
[/TD]
[TD]1
[/TD]
[TD]home
[/TD]
[TD]RD
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Leader Total : (Pers
[/TD]
[TD]Matt):5
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Scoring Center Total : 5
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I'd like to return a list that starts at say K1 (arbitrary) that would give me this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]VM
[/TD]
[TD]1234
[/TD]
[TD]Smith
[/TD]
[TD]John
[/TD]
[TD]8:30
[/TD]
[TD]Jones
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]4567
[/TD]
[TD]Rogers
[/TD]
[TD]Grant
[/TD]
[TD]8:30
[/TD]
[TD]Jones
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]3333
[/TD]
[TD]Grey
[/TD]
[TD]Luke
[/TD]
[TD]8:30
[/TD]
[TD]Pers
[/TD]
[/TR]
[TR]
[TD]VM
[/TD]
[TD]6666
[/TD]
[TD]Mann
[/TD]
[TD]Mark
[/TD]
[TD]8:30
[/TD]
[TD]Pers
[/TD]
[/TR]
</tbody>[/TABLE]
What I'm stumped on is how to define that range in Col I which changes with each new team. My approach is to find a way to search a range (essentially the values between blank cells ) in Col I for the value "SL", then search that same range in Col A for the value "VM". If there's a value of VM within that range (team), then copy Cols A-E, write them to a list, and insert that person's team leader last name at the right.
Any suggestions for how to define a dynamic range in Col I? Or maybe suggestions on how to approach the problem in a different manner? I already have a working macro written which generates that last time, sans team leader name, just trying to figure out how to search that changing range in Col I for each team to find team leader name.
Note, not all teams will have a member flagged with that VM marker in Col A.
Thanks for suggestions.