Sub PrintLabel()
Dim i&, j&, k&, c&, m&, n&
Dim sht As Worksheet
With ActiveSheet
c = .Cells.SpecialCells(xlCellTypeLastCell).Row
Do
n = n + 1
Loop Until .Cells(1, n) = "总件"
Set sht = Worksheets.Add
sht.Name = "PrintLabel"
sht.VPageBreaks.Add before:=sht.Cells(1, 5)
For i = 2 To c
If .Cells(i, 1) <> "" Then
For j = 2 To n - 1
For k = 1 To .Cells(i, j)
m = m + 4
sht.Cells(m - 2, 1) = .Cells(i, 1)
sht.Cells(m - 2, 2) = "总件"
sht.Cells(m - 2, 3) = n
sht.Cells(m - 1, 1) = .Cells(1, j)
sht.Cells(m - 1, 2) = k & "——" & .Cells(i, j)
sht.HPageBreaks.Add before:=sht.Cells(m + 1, 1)
Next k
Next j
End If
Next i
End With
sht.Columns.AutoFit
Set sht = Nothing
End Sub