Reputation: 1
I am currently working on an Excel VBA for the first time and I have managed to create a user form data can be entered from. I am currently looking for a code that would pop up upon successful saving of the data saying "data has been saved successfully" or "error! data not saved". How can I do that? Here is what I have so far
Private Sub cmdAddData_Click()
If ComboBox1.Value = "" Then
MsgBox "You must select your full name", vbCritical
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "You must select the full name of your 1st nominee", vbCritical
Exit Sub
End If
If ComboBox3.Value = "" Then
MsgBox "You must select the readiness level of your 1st nominee", vbCritical
Exit Sub
End If
Dim wks As Worksheet
Dim AddNew As Range
Set wks = Sheet6
Set AddNew = wks.Range("A65356").End(xlUp).Offset(1, 0)
AddNew.Offset(0, 0).Value = ComboBox1.Value
AddNew.Offset(0, 8).Value = ComboBox2.Value
AddNew.Offset(0, 18).Value = ComboBox3.Value
Upvotes: 0
Views: 5662
Reputation: 96771
A simple approach:
Sub qwerty()
s = Application.InputBox(Prompt:="enter a value", Type:=1)
[A1] = s
On Error GoTo issuewarning
ActiveWorkbook.Save
MsgBox "data has been saved successfully"
Exit Sub
issuewarning:
MsgBox "error! data not saved"
Exit Sub
End Sub
Upvotes: 1