- ©«¤l
- 976
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 1018
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-4-19
- ³Ì«áµn¿ý
- 2024-10-30
|
¦^´_ samwang
sam¤j
©êºpªí¹F¤£²M¡A²¨¥¤§´N¬O±N¦P¬ì¥Øª÷ÃB¶×Á`¦¨¤@µ§´N¦n...
Y¤£²M·¡¸ÔªþÀÉ¡A³Â·Ð±z ...
shuo1125 µoªí©ó 2022-5-31 10:12
½Ð¦A´ú¸Õ¬Ý¬Ý¡AÁÂÁÂ
Sub test()
Dim Arr, xD, Brr(), T$, T1$, i&, n%, n1%
Set xD = CreateObject("Scripting.Dictionary")
Set xD1 = CreateObject("Scripting.Dictionary")
Arr = Sheet1.[A1].CurrentRegion
For i = 2 To UBound(Arr)
T = Arr(i, 3): T1 = Arr(i, 5)
If UCase(T1) = "S" Then
xD(T) = Array(Arr(i, 2), Arr(i, 4), Arr(i, 7), Arr(i, 10))
End If
Next
Arr = Sheet2.[A1].CurrentRegion
ReDim Brr(1 To UBound(Arr), 1 To 7)
For i = 2 To UBound(Arr)
T = Arr(i, 1)
If xD.Exists(T) Then
T1 = xD(T)(0)
If xD1.Exists(T1) Then
n1 = xD1(T1)
If UCase(xD(T)(1)) = "DR" Then
If Arr(i, 10) > Arr(i, 11) Then
Brr(n1, 7) = Brr(n1, 7) + Arr(i, 10)
Else
Brr(n1, 7) = Brr(n1, 7) + Arr(i, 11)
End If
ElseIf UCase(xD(T)(1)) = "CR" Then
If Arr(i, 10) > Arr(i, 11) Then
Brr(n1, 7) = Brr(n1, 7) - Arr(i, 10)
Else
Brr(n1, 7) = Brr(n1, 7) - Arr(i, 11)
End If
End If
Else
n = n + 1: xD1(T1) = n: Brr(n, 3) = xD(T)(2)
Brr(n, 1) = xD(T)(0): Brr(n, 2) = xD(T)(3)
If UCase(xD(T)(1)) = "DR" Then
If Arr(i, 10) > Arr(i, 11) Then
Brr(n, 7) = Arr(i, 10)
Else
Brr(n, 7) = Arr(i, 11)
End If
ElseIf UCase(xD(T)(1)) = "CR" Then
If Arr(i, 10) > Arr(i, 11) Then
Brr(n, 7) = -Arr(i, 10)
Else
Brr(n, 7) = -Arr(i, 11)
End If
End If
End If
End If
99: Next
If n > 0 Then
With Sheet3
.[a7].CurrentRegion.Offset(5, 0) = ""
.[A8].Resize(n, 7) = Brr
.[G4] = Now
End With
Set xD = Nothing: Erase Arr, Brr
End If
End Sub |
-
-
1.JPG
(175.87 KB)
|