你能帮我解决我的问题吗,我想在我的程序中发生的是,当你在用户表单中的文本框中键入一个名称时,像这样“Vincent”,它会以同样的方式传递给工作表
Private Sub cmdAdd_Click()
If cmdAdd.Caption = "ADD" Then
txtName.Enabled = True: cboAge.Enabled = True:
cmdAdd.Caption = "SAVE": cmdClose.Caption = "CANCEL"
txtName.SetFocus
Else
If txtName.Text = "" Or cboAge.Text = "" Then
MsgBox "Required field(s) missing!", vbCritical, "Message"
Else
For i = 2 To Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
If LCase(txtName.Text) = Sheet1.Cells(i, 1).Value And _
cboAge.Text = Sheet1.Cells(i, 2).Value Then
MsgBox "Record already exist!", vbExclamation, "Message"
Call UserForm_Activate
Exit Sub
End If
Next i
r = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheet1.Cells(r, 1).Value = (txtName.Text)
Sheet1.Cells(r, 2).Value = cboAge.Text
r = 0
MsgBox "One record saved!", vbInformation, "Message"
Call UserForm_Activate
End If
End If
End Sub
这是代码你能帮我吗..谢谢