For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 12
j = (i - 1) / 4 + 1
SHN = j & "~" & j + 2 & "組"
On Error Resume Next: Set xS = Sheets(SHN): On Error GoTo 0
If xS Is Nothing Then Worksheets.Add(after:=Sheets(Sheets.Count)).Name = SHN
Set xS = Sheets(SHN)
.Cells(i, 1).Resize(12, 4).Copy xS.[A1]
For j = 1 To 4: xS.Cells(1, j).ColumnWidth = .Cells(1, j).ColumnWidth: Next
For j = 1 To 12: xS.Cells(j, 1).RowHeight = .Cells(j, 1).RowHeight: Next
Set xS = Nothing
Next i
End With
End Sub
複製代碼
================================
On Error Resume Next
Set xS = Sheets(SHN)
On Error GoTo 0
略過錯誤指令只針對 Set xS = Sheets(SHN),
過後還是要恢復偵錯功能,否則遇錯誤無法檢知,對資料的正確性有風險!!!作者: kerochen 時間: 2015-10-1 21:19