|
请高手帮我看看修改这个按钮什么地方出了问题。有时不能很准确的修改,也就是说,出现相同内容时只修改第一个内容而后面的不管点什么地方都是只是修改第一个内容别的不变。
Private Sub CommandButton4_Click()
Dim x%, y%, mrg As Range, DZ1$, DZ2$, DM$
With Sheets("客户表")
If MsgBox("你确实要修改当前窗口中的这些数据吗?", 4 + 32, "提示:") = vbNo Then
Exit Sub
End If
n = 电话.Text: y = .[f62233].End(xlUp).Row + 1
Set mrg = .Range("f2:f" & y).Find(n, lookat:=xlWhole)
x = mrg.Row: DZ1 = mrg.Address
If .Range("f" & x) = 电话.Text Then
.Range("c" & x) = 公司名称.Text
.Range("d" & x) = 联系人.Text
.Range("f" & x) = 电话.Text
.Range("e" & x) = 手机.Text
.Range("i" & x) = 地址.Text
.Range("b" & x) = 区域.Text
.Range("g" & x) = 信息.Text
.Range("h" & x) = 时间.Text
Else
Do
Set mrg = .Range("f2:f" & y).FindNext(mrg)
x = mrg.Row: DZ2 = mrg.Address: DM = .Range("f" & x)
If .Range("f" & x) = 电话.Text And DZ2 <> DZ1 Then
Range("c" & x) = 公司名称.Text:
.Range("d" & x) = 联系人.Text
.Range("f" & x) = 电话.Text:
.Range("e" & x) = 手机.Text
.Range("i" & x) = 地址.Text
.Range("b" & x) = 区域.Text:
.Range("g" & x) = 信息.Text
.Range("h" & x) = 时间.Text
Exit Sub
End If
Loop Until mrg.Address = DZ1
End If
End With
公司名称.Text = "": 联系人.Text = "": 电话.Text = "": 手机.Text = "": 信息.Text = ""
地址.Text = "": 区域.Text = "": 时间.Text = "":
End Sub
其他功能都已经实现,希望对大家有个帮助谢谢
|
|