|
楼主 |
发表于 2020-1-29 12:28
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <> 1 Then Exit Sub
If Target.Row < 3 Then Exit Sub
If Cells(Target.Row, 5) = "" Then Exit Sub
If Target.Column = 6 Then 'Exit Sub
Application.EnableEvents = False
If Target = "" Then
Cells(Target.Row, 7) = ""
Else
Cells(Target.Row, 7) = "第" & WorksheetFunction.CountIf([f3:f14], Target) & "个" & Target
For j = Target * 4 - 1 To Target * 4 + 2
If Len(Cells(j, 2)) = 0 Then
Cells(j, 2) = Cells(Target.Row, 5)
Exit For
End If
Next j
End If
Else
If Target.Column = 8 Then 'Exit Sub
Application.EnableEvents = False
If Target = "" Then
Cells(Target.Row, 9) = ""
Else
Cells(Target.Row, 9) = "第" & WorksheetFunction.CountIf([H3:H14], Target) & "个" & Target
For K = Target * 4 - 1 To Target * 4 + 2
If Len(Cells(K, 3)) = 0 Then
Cells(K, 3) = Cells(Target.Row, 5)
Exit For
End If
Next K
End If
Else
Exit Sub
End If
Exit Sub
End If
Application.EnableEvents = True
End Sub
|
|