|
各位老师:
请帮忙看看红色内容的这段代码为什么无法在附件中执行, 或者是以下代码无法全面执行 :将以下那段红色字体的代码放在前面是可执行了,但其它的代码却又无反应了, 因本人是个初学VBA的菜鸟, 以下的这些代码都是从本论坛各帖子中借鉴引用拼凑起来的, 有很多地方不懂, 自己经过好多次调试测试都无法解决, 只好又来求助,附上附件请各位走过路过的老师、高手指点迷津, 多谢!
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 6 Then Target = LCase(Target.Value)
On Error Resume Next
Application.EnableEvents = True
Dim crr, frr
With Sheet1
crr = .Range("b2:c135")
frr = .Range("e2:f25")
End With
If Target.Column = 6 Then
For i = 1 To UBound(crr)
If Target = crr(i, 1) Then Target = crr(i, 2): Exit Sub
Next i
ElseIf Target.Column = 5 Then
For i = 1 To UBound(frr)
If Target = frr(i, 1) Then Target = frr(i, 2): Exit Sub
Next i
Else
Exit Sub
End If
If Target.Column = 5 Then
Dim x&
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)
End If
If Target.Column = 5 Then
Cells(Target.Row, 3) = "散水"
Cells(Target.Row, 9) = "KG"
End If
If Target.Column <> 11 Then Exit Sub
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Target <> "" Then
Set c = Sheet1.Range("a1:a" & Sheet1.[a65536].End(xlUp).Row).Find(Target, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then Target.Offset(0, 0) = c
End If
Application.EnableEvents = True
End Sub
|
|