Private Sub CancelCommandButton_Click()
Unload Me
End Sub
Private Sub ClearCommandButton_Click()
Call UserForm_Initialize
End Sub
Private Sub OkCommandButton_Click()
Dim emptyRow As Long
Sheet1.Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 1).Value = EntityNameTextBox.Value
Cells(emptyRow, 2).Value = JurComboBox.Value
Cells(emptyRow, 3).Value = MailTypeComboBox.Value
End Sub
Private Sub UserForm_Initialize()
EntityNameTextBox.Value = ""
JurComboBox.Clear
With JurComboBox
.AddItem "AL"
.AddItem "AK"
.AddItem "AR"
.AddItem "AZ"
.AddItem "CA"
.AddItem "CO"
.AddItem "CT"
.AddItem "DE"
.AddItem "HI"
.AddItem "IA"
End With
MailTypeComboBox.Clear
With MailTypeComboBox
.AddItem "AR"
.AddItem "ARR"
.AddItem "DOR"
.AddItem "DTN"
.AddItem "FAR"
End With
EntityNameTextBox.SetFocus
End Sub
答案 0 :(得分:0)
请使用此代码:
Private Sub OkCommandButton_Click()
Dim emptyRow As Long
Dim MsgString as String
Sheet1.Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
MsgString = "Do you want to update data?" & vbNewLine & "A" & emptyRow & " = " & EntityNameTextBox.Value & vbNewLine & "B" & emptyRow & " = " & JurComboBox.Value & vbNewLine & "C" & emptyRow & " = " & MailTypeComboBox.Value
If MsgBox(MsgString, vbYesNo, "Update confirmation...!!!") = vbYes Then
Cells(emptyRow, 1).Value = EntityNameTextBox.Value
Cells(emptyRow, 2).Value = JurComboBox.Value
Cells(emptyRow, 3).Value = MailTypeComboBox.Value
Else
Msgbox "Data Update failed.", vbExclamation, "Failed update data."
End If
End Sub
希望得到这个帮助。