|
- Sub 数据合并()
- Dim Qssj, Lj As String, Wj As String, Xm As String, Sj As Double
- Dim Rq As Long, Xrl As Long, Xrh As Long, Qsh As Long, i3 As Long, i4 As Long
- Dim i1 As String, i2 As String
- On Error Resume Next
- Qssj = Timer
- Lj = ThisWorkbook.Path & "\00"
- i1 = InputBox("请输入开始日期:yyyy-m-d")
- If i1 = "" Then Exit Sub
- i2 = InputBox("请输入结束日期:yyyy-m-d")
- If Len(i2) = 0 Then Exit Sub
- i3 = Val(Format(i1, "d"))
- i4 = Val(Format(i2, "d"))
- Application.ScreenUpdating = False
- Range("D3:AI59").ClearContents
- For x = i3 To i4
- tt = Format(i1, "yyyy-mm") & "-" & Format(x, "00")
- Wj = Dir(Lj & tt & ".xls")
- Workbooks.Open (Lj & Wj)
- Rq = Mid(tt, 9, 2)
- Xrl = Rq + 3
- With ActiveWorkbook.Sheets("花名冊")
- For i = 40 To 55
- Qsh = Range("B2:B50").Find(.Cells(1, i)).Row
- For j = 2 To 7
- Sj = .Cells(j, i)
- Xm = .Cells(j, 39)
- Select Case Xm
- Case "生產數量"
- Xrh = Qsh
- Cells(Xrh, Xrl) = Cells(Xrh, Xrl) + Sj
- Cells(Xrh, 35) = Cells(Xrh, 35) + Sj
- Case "生產時間"
- Xrh = Qsh + 1
- Cells(Xrh, Xrl) = Cells(Xrh, Xrl) + Sj
- Cells(Xrh, 35) = Cells(Xrh, 35) + Sj
- Case "生產面積"
- Xrh = Qsh + 2
- Cells(Xrh, Xrl) = Cells(Xrh, Xrl) + Sj
- Cells(Xrh, 35) = Cells(Xrh, 35) + Sj
- End Select
- Next j
- Next i
- End With
- ActiveWorkbook.Close True
- Next x
- Application.ScreenUpdating = True
- MsgBox "共用时" & Round((Timer - Qssj), 0) & "秒!"
- End Sub
复制代码 |
评分
-
查看全部评分
|