|
发表于 2013-4-30 09:40
|
显示全部楼层
本楼为最佳答案
- Sub test()
- Dim arr
- Dim lLastRow&
- Dim str As String * 5, strSheetName$
- str = "一二三四五"
- With Worksheets("凭证信息录入")
- lLastRow = .Cells(Rows.Count, 2).End(xlUp).Row
- If lLastRow < 3 Then MsgBox "无有效数据": Exit Sub
- arr = .Range("b3:m" & lLastRow).Value
- End With
- Application.ScreenUpdating = False
- For i = LBound(arr) To UBound(arr)
- On Error Resume Next
- strSheetName = "第" & Mid(str, CInt(Left(arr(i, 5), 1)), 1) & "工序"
- 'Debug.Print strSheetName, i
- If Err.Number = 0 Then
- With Worksheets(strSheetName)
- .Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 12) = WorksheetFunction.Index(arr, i, 0)
- End With
- End If
- Err.Clear
- Next
- Application.ScreenUpdating = True
- MsgBox "数据整理完成", vbInformation
- End Sub
复制代码 |
|