|
求助大神指点下,弄了个窗体录入,但只能在客户信息工作表上,调出窗体录入数据会保存到客户信息表上,在其它工作表调出窗体录入数据不会保存到客户信息表上,只保存到当前活动工作表中,我想要的效果是在任何一个工作表上调出该窗体录入数据都能保存在客户信息表上,而不限于只能在客户信息表调出录入,才能保存到客户信息表中……详细如附件
信息录入.zip
(165.55 KB, 下载次数: 17)
文件中有代码,求助大神,稍作指点修改下,谢谢!
Private Sub CommandButton1_Click()
If TextBox1.Text = "" Then MsgBox "客户信息": Exit Sub
If TextBox2.Text = "" Then MsgBox "新编号": Exit Sub
Dim Rng As Range
Dim i As Integer
Set Rng = Sheets("客户信息").Columns(5).Find(TextBox2.Value, lookat:=xlWhole)
If Not Rng Is Nothing Then '号已存在
MsgBox "该编号已存在!!": Exit Sub
End If
' Sheet2.Unprotect ("a2023")
With Sheets("客户信息")
i = Sheets("客户信息").Range("A1048576").End(xlUp).Row + 1
If i = 2 Then
Cells(i, 1) = 1
Cells(i, 3) = TextBox1.Value
Cells(i, 5) = TextBox2.Value
Else
Cells(i, 3) = Cells(i - 1, 1) + 1
Cells(i, 3) = TextBox1.Value
Cells(i, 5) = TextBox2.Value
End If
' Call客户排序
TextBox1.Value = ""
TextBox2.Value = ""
'Sheet2.Protect ("a2023")
End With
End Sub
|
|