|
本帖最后由 hwc2ycy 于 2012-9-9 20:34 编辑
- Private Sub CommandButton1_Click()
- Dim Mr As Integer
- Dim rng As Range
- Dim what As String
- Dim rw As Long
- Dim frg As Range
- If Application.CountIf(Sheets("客户资料").Range("B:B"), TextBox2.Value) >= 1 Then
- MsgBox "该客户号已经被使用,请重新输入"
- Exit Sub
- End If
-
- If Len(TextBox3.Value) = 0 Then
- MsgBox "客户名称未输入,请重新输入"
- Exit Sub
- End If
-
- With Sheets("客户资料")
- Mr = .Range("B65536").End(xlUp).Row + 1
- If Len(TextBox9.Value) > 0 Then
- Set frg = Range("b:b").Find(TextBox9.Value, Lookat:=xlWhole)
- If frg Is Nothing Then
- MsgBox "客户号有误,请重新输入"
- Exit Sub
- End If
- frg.Offset(1).EntireRow.Insert
- Mr = frg.Row + 1
- End If
- Cells(Mr, 1).Formula = "=row()-1"
- Cells(Mr, 2) = TextBox2.Value
- Cells(Mr, 3) = TextBox3.Value
- Cells(Mr, 4) = TextBox4.Value
- Cells(Mr, 5) = TextBox5.Value
- Cells(Mr, 6) = TextBox6.Value
- Cells(Mr, 7) = TextBox7.Value
- Cells(Mr, 8) = TextBox8.Value
- Cells(Mr, 9).Formula = "=PINY(C" & Mr & ")"
- MsgBox "添加完成"
- End With
- End Sub
- Private Sub UserForm_Initialize()
- TextBox2.Value = Sheets("客户资料").Range("j1")
- End Sub
复制代码 |
评分
-
查看全部评分
|