How to write EXCEL VBA code of serpentine arrangement of sports meeting?

Public? Sub? mySub()

For the sake of beauty, a simple format was designed, and the group started with five elements.

Dim? startLine? As? integer

startLine? =? five

Give sheet 1 an alias for coding.

Dim? sT? As? worksheet

Settings? sT? =? Paper ("paper 1")

Read in the number of people and groups.

Dim? Team? People? As? integer

Team? =? Sacred cell (1, 2). Value

People? =? Sacred cells (2, 2). Value

For what? Me? =? startLine? Where to? startLine? +? Team? -? 1

Write down the name of the team.

Sacred cell (I, 1). Value? =? "Team?" ? & amp? Str (me? -? startLine? +? 1)

Next? I

Flag is used to generate a snake, which is equal to one from top to bottom; Is equal to minus one, and vice versa.

Dim? Flag? As? integer

Flag? =? 1

This is the parameter of the control bar.

Dim? currentCol? As? integer

currentCol? =? 2

This is the personnel number. In the Do loop, add one at a time.

Dim? currentPerson? As? integer

currentPerson? =? 1

These are the start and end values of the for loop every time a number is filled.

Dim? s,? e? As? integer

do

What if? Flag? =? 1? then

s? =? 1

e? =? group

other

s? =? group

e? =? 1

End? if

Start filling in the numbers

For what? j? =? s? Where to? e? One step? a kind of ancient banner

Sacred cell (startLine? +? j? -? 1,? currentCol)。 Value? =? Current personnel

currentPerson? =? currentPerson? +? 1

Next? j

After filling in a column, adjust the variable value.

currentCol? =? currentCol? +? 1

Flag? =? (- 1)? *? a kind of ancient banner

What if? currentPerson? & gt? People? then what Quit submarine

ring

End? submarine