|
楼主 |
发表于 2023-3-26 15:03
|
显示全部楼层
看老师的视频改的,能用
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) <> "I1" Then Exit Sub
If Len(Target) = 0 Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
r = 2
Range("a:h").ClearContents
arr = Sheets("内容二").UsedRange
For j = 2 To UBound(arr)
If arr(j, 6) = Target Then
If Target = "1228" Then
Range("N1:R1").Copy Range("A1:E1")
Cells(r, 1) = arr(j, 2)
Cells(r, 2) = arr(j, 3)
Cells(r, 3) = arr(j, 4)
Cells(r, 4) = arr(j, 5)
Cells(r, 5) = arr(j, 7)
r = r + 1
ElseIf Target = "1108" Then
Range("N2:T2").Copy Range("A1:G1")
Cells(r, 1) = arr(j, 2)
Cells(r, 2) = arr(j, 3)
Cells(r, 3) = arr(j, 4)
Cells(r, 6) = arr(j, 5)
Cells(r, 7) = arr(j, 7)
r = r + 1
End If
End If
Next j
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub |
|