|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- tt = Timer
- For Each ws In Worksheets
- If ws.Name <> "线上产品运营" Then
- Set d(ws.Name) = CreateObject("scripting.dictionary")
- With ws
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:o" & r)
- For i = 1 To UBound(arr)
- d(ws.Name)(arr(i, 3)) = Array(arr(i, 4), arr(i, 5), arr(i, 6), arr(i, 7), arr(i, 8), arr(i, 9), arr(i, 10))
- Next
- End With
- End If
- Next
- With Worksheets("线上产品运营")
- .AutoFilterMode = False
- cs = .Range("a2:l2")
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- c = .Cells(4, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a3").Resize(r - 2, c)
- For i = 3 To UBound(arr)
- If d.exists(arr(i, 7)) Then
- For j = 11 To UBound(arr, 2) Step 2
- If d(arr(i, 7)).exists(arr(1, j)) Then
- brr = d(arr(i, 7))(arr(1, j))
- If arr(i, 9) > brr(0) And arr(i, 9) < brr(1) Then
- If arr(i, 9) <= brr(2) Then
- arr(i, j + 1) = (arr(i, 8) + brr(3) + brr(6) + cs(1, 12)) / (1 - cs(1, 5) - cs(1, 7) - cs(1, 9)) / 0.6
- Else
- f2 = brr(4) + Application.Ceiling((arr(i, 9) - brr(2)) / brr(4), 1) * brr(5) + brr(6)
- arr(i, j + 1) = (arr(i, 8) + f2 + cs(1, 12)) / (1 - cs(1, 5) - cs(1, 7) - cs(1, 9)) / 0.6
- End If
- End If
- End If
- Next
- End If
- Next
- .Range("a3").Resize(r - 2, c) = arr
- End With
- Application.ScreenUpdating = True
- MsgBox Timer - tt
- End Sub
复制代码 |
|