|
楼主 |
发表于 2023-6-20 14:43
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这样试着合并了一下,但是下半部分不能触发事件,拜求各位大师
Private Sub Worksheet_Change(ByVal Target As Range) '自动取客户信息
On Error Resume Next
Dim Rng As Range
Application.EnableEvents = False '禁止触发事件
Set Rng = Range("j5") '你需要的单元格区域
If Intersect(Target, Rng) Is Nothing Then '选择单元不在区内就退出
Application.EnableEvents = True '允许触发事件
Exit Sub
End If
On Error GoTo 100
Target.Value = Target.Value * 5
Application.ScreenUpdating = True
100:
If Err.Number = 13 Then
End If
'Application.EnableEvents = True
'从这里往下不能触发事件
If Target.Address <> "$B$2" Then Exit Sub
Dim Arr, i&, d
Set d = CreateObject("Scripting.Dictionary")
S = Cells(2, 2)
bz = False
For i = 2 To Worksheets("客户资料").Cells(Rows.Count, 1).End(3).Row
If Worksheets("客户资料").Cells(i, 2) = S Then
bz = True
Exit For
End If
Next i
If Not bz Then
[g2] = ""
[j2] = ""
[o2] = ""
[d3] = ""
[k3] = ""
[a5] = ""
[d5] = ""
[f5] = ""
[g5] = ""
[h5] = ""
[i5] = ""
[k5] = ""
[n5] = ""
[c8] = ""
[g8] = ""
[m8] = ""
MsgBox "该车号的客户资料不存在"
Else
Arr = Sheet7.[a1].CurrentRegion
For i = 2 To UBound(Arr)
If Arr(i, 2) = "" Then Exit For
d(Arr(i, 2)) = i
Next
If [b2] = "" Then Exit Sub
'End If
i = d(Target.Value)
[g2] = Arr(i, 3): [j2] = Arr(i, 4): [o2] = Arr(i, 5): [c8] = Arr(i, 6): [g8] = Arr(i, 7): [m8] = Arr(i, 8)
End If
End Sub
|
|