|
楼主 |
发表于 2018-10-9 22:56
|
显示全部楼层
本帖最后由 hexaking 于 2018-10-9 23:02 编辑
- Sub autodb()
- Dim r As Integer
- Dim w As Integer
- Dim i As Integer
- Dim q As Integer
- Dim y As Workbook
- Dim b As Workbook
- Dim FD
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- FD = ThisWorkbook.Sheets("Sheet1").Range("K3")
- For w = 1 To ThisWorkbook.Sheets("Sheet1").Range("L3")
- For r = 1 To 45
- Set y = Workbooks.Open("D:\Program Files (x86)\Desktop\资料\F\test" & Format(FD, "yyyy-m-d") & ".xlsx") '引用值(不同日期需修改)
- Set b = Workbooks.Open("D:\Program Files (x86)\Desktop\FC表\F\C" & r & ".xls")
- i = Worksheets.Count
- For q = 1 To i
- If b.Worksheets(q).Range("E24") = "" Then
- b.Worksheets(q).Activate
- Exit For
- Else
- End If
- Next q
- If r < 23 Then
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("C ").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("C ").Cells(10 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("C ").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("C ").Cells(10 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- Else
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("C ").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("C ").Cells(35 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("C ").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("C ").Cells(35 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- End If
- b.Close 1
- Next r
- FD = DateAdd("d", ThisWorkbook.Sheets("Sheet1").Range("M3"), FD)
- Next w
- Application.ScreenUpdating = True
- Application.Calculation = xlCalculationAutomatic
- End Sub
- Sub autopc()
- Dim r As Integer
- Dim w As Integer
- Dim i As Integer
- Dim q As Integer
- Dim y As Workbook
- Dim b As Workbook
- Dim FD
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- FD = ThisWorkbook.Sheets("Sheet1").Range("K3")
- For w = 1 To ThisWorkbook.Sheets("Sheet1").Range("L3")
- For r = 1 To 30
- Set y = Workbooks.Open("D:\Program Files (x86)\Desktop\资料\F\test" & Format(FD, "yyyy-m-d") & ".xlsx") '引用值(不同日期需修改)
- Set b = Workbooks.Open("D:\Program Files (x86)\Desktop\FC表\F\PC" & r & ".xls")
- i = Worksheets.Count
- For q = 1 To i
- If b.Worksheets(q).Range("E24") = "" Then
- b.Worksheets(q).Activate
- Exit For
- Else
- End If
- Next q
- If r < 23 Then
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("PC").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("PC").Cells(10 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("PC").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("PC").Cells(10 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- Else
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("PC").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("PC").Cells(35 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("PC").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("PC").Cells(35 + r, 3) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- End If
- b.Close 1
- Next r
- FD = DateAdd("d", ThisWorkbook.Sheets("Sheet1").Range("M3"), FD)
- Next w
- Application.ScreenUpdating = True
- Application.Calculation = xlCalculationAutomatic
- End Sub
- Sub autops()
- Dim r As Integer
- Dim w As Integer
- Dim i As Integer
- Dim q As Integer
- Dim y As Workbook
- Dim b As Workbook
- Dim FD
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- FD = ThisWorkbook.Sheets("Sheet1").Range("K3")
- For w = 1 To ThisWorkbook.Sheets("Sheet1").Range("L3")
- For r = 1 To 30
- Set y = Workbooks.Open("D:\Program Files (x86)\Desktop\资料\F\test" & Format(FD, "yyyy-m-d") & ".xlsx") '引用值(不同日期需修改)
- Set b = Workbooks.Open("D:\Program Files (x86)\Desktop\FC表\F\SY" & r & ".xls")
- i = Worksheets.Count
- For q = 1 To i
- If b.Worksheets(q).Range("E24") = "" Then
- b.Worksheets(q).Activate
- Exit For
- Else
- End If
- Next q
- If r < 23 Then
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("PSY").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("PSY").Cells(10 + r, 4) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("PSY").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("PSY").Cells(10 + r, 4) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- Else
- If ActiveSheet.Range("A24") = "" Then
- y.Sheets("PSY").Cells(5, 2).Copy
- ActiveSheet.Range("A25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("B25").End(xlUp).Offset(1, 0) = y.Sheets("PSY").Cells(35 + r, 4) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- Else
- y.Sheets("PSY").Cells(5, 2).Copy
- ActiveSheet.Range("E25").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues '日期(不同日期需修改)
- ActiveSheet.Range("F25").End(xlUp).Offset(1, 0) = y.Sheets("PSY").Cells(35 + r, 4) * 1000 '本次测值(不同日期需修改)
- y.Close 0
- End If
- End If
- b.Close 1
- Next r
- FD = DateAdd("d", ThisWorkbook.Sheets("Sheet1").Range("M3"), FD)
- Next w
- ThisWorkbook.Sheets("Sheet1").Range("K3") = Format(FD, "yyyy-m-d")
- Application.ScreenUpdating = True
- Application.Calculation = xlCalculationAutomatic
- End Sub
复制代码
|
|