I am creating a personal finance tracker where a user enters their purchase information in order to track their daily/weekly/yearly spending. Upon submitting the User Form, the information simply populates a raw data source that feeds into many pivot tables and charts. For my own personal benefit, I would like a warning message to appear if the form submission produces the exact same row as the most current (or last) row in the raw data table. Here is the code I have for the Submission Button in the User Form:
If a duplicate is submitted, I would like the user to be asked whether or not they would like to continue with the submission. If they click "no" a message box will appear saying "Submission cancelled." If they click "yes," a message box will appear saying "Submission Successful!"
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, 3).Value = MonthComboBox.Value
Cells(emptyRow, 4).Value = DayTextBox.Value
Cells(emptyRow, 5).Value = YearTextBox.Value
'Cells(emptyRow, 5).Value = MonthComboBox.Value & " " & DayTextBox & ", " & YearTextBox
Cells(emptyRow, 6).Value = CategoryComboBox.Value
Cells(emptyRow, 7).Value = SubcategoryComboBox.Value
Cells(emptyRow, 8).Value = NotesTextBox.Value
Cells(emptyRow, 9).Value = PriceTextBox.Value
Cells(emptyRow, 10).Value = ConsumerComboBox.Value
Cells(emptyRow, 11).Value = WithdrawalTextBox.Value
Cells(emptyRow, 12).Value = DepositTextBox.Value
MsgBox "Submission Successful!"
End Sub
If a duplicate is submitted, I would like the user to be asked whether or not they would like to continue with the submission. If they click "no" a message box will appear saying "Submission cancelled." If they click "yes," a message box will appear saying "Submission Successful!"