|
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim r%, i%
- Dim arr, brr(), crr()
- Dim hg(1 To 22)
- If Target.Count > 1 Then
- Exit Sub
- End If
- If Target.Address = "$F$4" Then
- bh = Target.Value
- With Worksheets("数据库")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:v" & r)
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 22) = bh Then
- m = m + 1
- ReDim Preserve brr(1 To m)
- brr(m) = i
- End If
- Next
- End With
- If m = 0 Then
- MsgBox "没有符合条件数据!"
- Exit Sub
- End If
- With Worksheets("委托")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- If r > 22 Then
- .Rows("23:" & r).Delete
- End If
- For i = 1 To 22
- hg(i) = .Rows(i).RowHeight
- Next
- End With
- r = 23
- For k = 1 To UBound(brr) Step 11
- ReDim crr(1 To 11, 1 To 8)
- For i = 1 To Application.Min(11, UBound(brr) - k + 1)
- crr(i, 1) = k + i - 1
- crr(i, 2) = arr(brr(k + i - 1), 4)
- crr(i, 3) = arr(brr(k + i - 1), 4)
- crr(i, 4) = arr(brr(k + i - 1), 5)
- crr(i, 5) = arr(brr(k + i - 1), 10)
- crr(i, 6) = arr(brr(k + i - 1), 9)
- crr(i, 7) = arr(brr(k + i - 1), 8)
- crr(i, 8) = arr(brr(k + i - 1), 11)
- Next
- If i <= 11 Then
- crr(i, 2) = "以下空白"
- End If
- With Worksheets("委托")
- .Range("a10").Resize(UBound(crr), UBound(crr, 2)) = crr
- .Range("a1:h22").Copy .Cells(r, 1)
- For i = 1 To UBound(hg)
- .Rows(r + i - 1).RowHeight = hg(i)
- Next
- r = r + 22
- End With
- Next
- With Worksheets("委托")
- .Range("a1:h22").Delete shift:=xlUp
- End With
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|