|
富之宝 发表于 2013-12-12 18:26
很多表都是那样做的,现在我需要整理这些数据,,从2010年到现在,一个一个的做好慢啊,不知能否用代码实现, ...
参考- Sub Button1_Click()
- Dim i, sNum, sPono
- [a2:d2] = Array("客户", "生产单号", "总数量", "物料名称", "颜色")
- With CreateObject("vbscript.regexp")
- .Pattern = "\d+PCS" '数量
- sNum = Replace(.Execute([o1])(0), "PCS", "")
- .Pattern = "\D{2}-\d{7}"
- sPono = .Execute([o1])(0) '订单号
- End With
- For i = 3 To [e65536].End(3).Row Step 3
- If Cells(i + 2, "E") = "" And Cells(i + 1, "E") <> "" And Cells(i, "E") <> "" Then
- Cells(i + 1, "D") = Cells(i, "E")
- Cells(i, "E") = ""
- Cells(i + 1, "C") = sNum
- Cells(i + 1, "B") = sPono
- End If
- Next
- For i = ActiveSheet.UsedRange.Rows.Count To 3 Step -1
- If Cells(i, "E") = "" Then Cells(i, "E").EntireRow.Delete
- Next
- [1:1].Delete
- End Sub
复制代码
|
|