|
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- Application.EnableEvents = False
- Dim Arr, x&, i&, c
- With Sheet1
- Arr = .UsedRange
- End With
- If Target.Column = 6 Then
- Target = LCase(Target.Value)
- For i = 2 To UBound(Arr)
- If Target = Arr(i, 2) Then Target = Arr(i, 3): Exit Sub
- Next i
- ElseIf Target.Column = 5 Then
- For i = 2 To UBound(Arr)
- If Target = Arr(i, 5) Then Target = Arr(i, 6): Exit Sub
- Next i
- x = Sheet1.Range("f" & Cells.Rows.Count).End(3).Row
- Cells(Target.Row, 2) = Application.VLookup(Cells(Target.Row, 5), Sheet1.Range("f1:g" & x), 2, 0)
- Cells(Target.Row, 3) = "散水"
- Cells(Target.Row, 9) = "KG"
- ElseIf Target.Column = 11 Then
- If Target <> "" Then
- Set c = Sheet1.[a:a].Find(Target, LookIn:=xlValues, lookat:=xlPart)
- If Not c Is Nothing Then Target.Offset(0, 1) = c
- End If
- Else
- Exit Sub
- End If
- Application.EnableEvents = True
- End Sub
复制代码 |
|