|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 规范清单()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
With Sheets("报表 1")
r = .Cells(Rows.Count, 7).End(xlUp).Row
If r < 2 Then MsgBox "报表 1为空!": End
ar = .Range("g1:g" & r)
End With
ReDim br(1 To 100000, 1 To 2)
n = 1
br(n, 1) = "序号"
br(n, 2) = "规范号"
For i = 2 To UBound(ar)
If Not IsError(ar(i, 1)) Then
If Trim(ar(i, 1)) <> "" Then
If InStr(ar(i, 1), "|") > 0 Then
If InStr(ar(i, 1), Chr(10)) = 0 Then
n = n + 1
br(n, 1) = n - 1
mr = Split(ar(i, 1), "|")
br(n, 2) = mr(UBound(mr))
Else
rr = Split(ar(i, 1), Chr(10))
For s = 0 To UBound(rr)
If InStr(rr(s), "|") > 0 Then
n = n + 1
br(n, 1) = n - 1
mr = Split(rr(s), "|")
br(n, 2) = mr(UBound(mr))
End If
Next s
End If
End If
End If
End If
Next i
If n = 1 Then MsgBox "没有需要汇总的规范号!": End
Set wb = Workbooks.Add
With wb.Worksheets(1)
.[a1].Resize(n, 2) = br
End With
wb.SaveAs Filename:=ThisWorkbook.Path & "\规范清单.xlsx"
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|