Nice program. I’ve got a few recommendations.
Your readme doc could use a little more explanation on how to use the system. For example, what values do your scouters put in their sheets?
At the beginning you ask for the number of teams. You can get this automatically with code similar to:
With Worksheets("Team List")
Set r = .Range(.Cells(2, "A"), .Cells(2, "A").End(xlDown))
End With
For Each cell In r
TeamNumber = cell.Value
' do something like create a worksheet with it
Next
It look like you are programmatically creating the team sheets. While this is a cool excercise in programming, I prefer to create a template sheet, then copy it. This allows me to use the built in WYSIWYG editor provided by Excel. The complete logic I’m using to create sheets from a list of team #'s is:
Sub Create_Teams()
’ Deletes existing team sheets, then creates one sheet per team represented in a
’ list of teams.
’
’ Assumes teams are in worksheet “Team List”,
’ and a team template sheet “Team Template” exists
Dim r As Range, cell As Range
’ Confirm this is what they want to do, sheets will be blown away
If (MsgBox(“Executing this routine will destroy the contents of any existing team sheets. Continue?”, vbYesNo, “Warning”) = vbYes) Then
Application.DisplayAlerts = False ’ get rid of annoying confirmation of delete for each
For Each Sheet In ThisWorkbook.Sheets
If (Left(Sheet.Name, 2) = “T-”) Then ’ if sheet begin with “T-” delete it
Sheet.Delete
End If
Next
Application.DisplayAlerts = True ’ turn alerts back on
With Worksheets("Team List") ' get a collection of cells, starting a A2, going down
Set r = .Range(.Cells(2, "A"), .Cells(2, "A").End(xlDown))
End With
For Each cell In r ' for each team #
LastSheet = Sheets.Count ' get last sheet #
TeamNumber = cell.Value ' copy team #
Sheets("Team Template").Copy After:=Sheets(LastSheet) ' copy template sheet to new sheet at end
Sheets(LastSheet + 1).Name = "T-" & TeamNumber ' rename sheet to T-<team #> '
Sheets(LastSheet + 1).Range("B1").Value = TeamNumber ' set one of the cells in new sheet to team #
Next
End If
End Sub
I’m no expert on programming Excel. This is just a bunch of code I’ve cobbled together based on previous VB programming experience and lots of Google searches. There is probably plenty of room for improvement on this code.
Good luck