I am completely new to VBA and have learned quite a bit in the last week by working slowly on a personal project of mine. I have most of the essentials set up, but it is imperative that I provide the user the ability to undo a data submission when using a User Form.
My submission code is as follows:
How can I allow an undo button to clear the most recent submission? Would it be as simple as writing code to delete the row above the first empty row?
My submission code is as follows:
Code:
Private Sub SubmitCommandButton_Click()
Dim emptyRow As Long
'Make Raw Data Sheet Active
Sheet4.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = MonthComboBox.Value
Cells(emptyRow, 2).Value = DayTextBox.Value
Cells(emptyRow, 3).Value = YearTextBox.Value
Cells(emptyRow, 4).Value = CategoryComboBox.Value
Cells(emptyRow, 5).Value = SubcategoryComboBox.Value
Cells(emptyRow, 6).Value = NotesTextBox.Value
Cells(emptyRow, 7).Value = PriceTextBox.Value
Cells(emptyRow, 8).Value = ConsumerComboBox.Value
Cells(emptyRow, 9).Value = WithdrawalTextBox.Value
Cells(emptyRow, 10).Value = DepositTextBox.Value
MsgBox "Submission Successful!"
End Sub
How can I allow an undo button to clear the most recent submission? Would it be as simple as writing code to delete the row above the first empty row?