'都输出了,只是输出表格格式还是有问题
'插入一个新工作表:sheet1,按我的方式给你输出
Option Explicit
Sub test()
Dim i, arr, m, pos, p
Application.ScreenUpdating = False
On Error GoTo errmsg
arr = Sheets("1").[a1].CurrentRegion.Offset(1)
arr(UBound(arr, 1), 1) = "?"
ReDim brr(1 To 17, 1 To 1), crr(1 To 17, 1 To 1)
pos = 1: p = 2
With Sheets("sheet1")
.Cells.ClearContents
For i = 1 To UBound(arr, 1) - 1
m = m + 1
brr(m, 1) = arr(i, 2): crr(m, 1) = arr(i, 3)
If Len(arr(i + 1, 1)) Then
.Cells(4, p).Resize(UBound(brr)) = brr
.Cells(22, p).Resize(UBound(brr)) = crr
.Cells(41, p) = arr(pos, 1)
.Cells(1, p) = "保管期限"
.Cells(3, p) = "个人编号"
.Cells(21, p) = "姓名"
.Cells(40, p) = "组号"
m = 0: pos = i + 1: p = p + 2
ReDim brr(1 To 17, 1 To 1), crr(1 To 17, 1 To 1)
End If
Next
.Columns(1).Resize(, p).AutoFit
End With
Application.ScreenUpdating = True
Exit Sub
errmsg:
Application.ScreenUpdating = True
MsgBox "检查是否存在:sheet1"
End Sub |