增加需求。- Sub ykcbf2() '//2024.11.14
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- bt = [{"高","低"}]
- For x = 1 To UBound(bt)
- With Sheets("每日最" & bt(x) & "(公)")
- r = .Cells(Rows.Count, 2).End(3).Row
- c = .Cells(1, Columns.Count).End(1).Column
- .[k2].Resize(r, 4) = ClearContents
- arr = .[a1].Resize(r, c)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 2) & bt(x)
- n = 0
- For j = IIf(x = 1, 27, 28) To UBound(arr, 2) '//日期超始列号自A列开始数的第27列(最高值)、第28列(最低值)
- If arr(i, j) <> Empty Then
- n = n + 1
- If Not d.exists(s) Then
- d(s) = Array(arr(i, j), arr(1, j), arr(i, j), arr(1, j))
- Else
- t = d(s)
- t(0) = IIf(IIf(x = 1, t(0) > arr(i, j), t(0) < arr(i, j)), t(0), arr(i, j))
- t(1) = IIf(IIf(x = 1, t(0) > arr(i, j), t(0) < arr(i, j)), t(1), arr(1, j))
- t(2) = IIf(n <= 10, IIf(IIf(x = 1, t(2) > arr(i, j), t(2) < arr(i, j)), t(2), arr(i, j)), t(2))
- t(3) = IIf(n <= 10, IIf(IIf(x = 1, t(2) > arr(i, j), t(2) < arr(i, j)), t(3), arr(1, j)), t(3))
- d(s) = t
- End If
- End If
- Next
- Next
- Next
- With Sheets("1判每日取数判断(公)")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 18)
- For x = 1 To UBound(bt)
- For i = 2 To UBound(arr)
- s = arr(i, 2) & bt(x)
- If d.exists(s) Then
- arr(i, IIf(x = 1, 11, 13)) = d(s)(0) '//日期超始列号最高值金额在自A列开始数的第11列,最高值日期在13列
- arr(i, IIf(x = 1, 12, 14)) = d(s)(1) '//日期超始列号最低值金额在自A列开始数第12列,最高值日期在14列
- arr(i, IIf(x = 1, 15, 17)) = d(s)(2) '//10日内,日期超始列号最高值金额在自A列开始数的第15列,最高值日期在17列
- arr(i, IIf(x = 1, 16, 18)) = d(s)(3) '//10日内,日期超始列号最低值金额在自A列开始数第16列,最高值日期在18列
- End If
- Next
- Next
- .Columns(2).NumberFormatLocal = "@"
- .[a1].Resize(r, 18) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|