|
请见代码。
- Dim xh$, Arr00, n&
- Dim wl, sl, r1, gx, Arr02, jt, yl, d1
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- If Target = "" Then Exit Sub
- If Target.Column <> 1 Or Target.Row < 2 Then Exit Sub
- Dim i&, t, aa, j&
- Application.EnableEvents = False
- xh = Target.Value: n = Target.Row - 1
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Arr00 = Sheet3.[a1].CurrentRegion
- For i = 3 To UBound(Arr00)
- d(Arr00(i, 16)) = d(Arr00(i, 16)) & i & ","
- Next
- Arr02 = Sheet5.[a1].CurrentRegion
- For i = 3 To UBound(Arr02)
- d1(Arr02(i, 2)) = d1(Arr02(i, 2)) & i & ","
- Next
- If d.exists(xh) Then
- t = d(xh)
- t = Left(t, Len(t) - 1)
- If InStr(t, ",") Then
- aa = Split(t, ",")
- For j = 0 To UBound(aa)
- Call yy(aa(j))
- Next
- Else
- Call yy(t)
- End If
- End If
- Application.EnableEvents = True
- End Sub
- Sub yy(i)
- Dim tt, aa, j&, r1
- wl = Arr00(i, 27): sl = Arr00(i, 6)
- Set r1 = Sheet4.[c:c].Find(wl, , , 1)
- If Not r1 Is Nothing Then
- gx = r1.Offset(0, -1).Value
- If d1.exists(gx) Then
- tt = d1(gx)
- tt = Left(tt, Len(tt) - 1)
- If InStr(tt, ",") Then
- aa = Split(tt, ",")
- For j = 0 To UBound(aa)
- jt = Arr02(aa(j), 1)
- Call fz(jt)
- Next
- Else
- jt = Arr02(tt, 1)
- Call fz(jt)
- End If
- End If
- End If
- End Sub
- Sub fz(jt)
- Dim r1
- Set r1 = Sheet6.[a:a].Find(jt, , , 1)
- If Not r1 Is Nothing Then
- yl = Sheet6.Cells(r1.Row, 7)
- n = n + 1
- Cells(n, 1) = xh
- Cells(n, 2) = wl
- Cells(n, 3) = sl
- Cells(n, 4) = gx
- Cells(n, 5) = jt
- Cells(n, 6) = yl
- Cells(n, 7) = sl / yl * 60
- End If
- End Sub
复制代码 |
|