I have a macro that adds records to a table if another table has a new row added.
It works fine and doesn't produce errors.
There are times however when it adds records when no new row was added to the feeder table.
Is there something in the code that makes it run anyway?
Sometimes, I'm working in the feeder table, and then I go check the records table and a new set of records has been added, even though no new rows were added.
Is there a way to add a message box that asks if you meant to add a new record and if you click no, it stops this from running?
It works fine and doesn't produce errors.
There are times however when it adds records when no new row was added to the feeder table.
Is there something in the code that makes it run anyway?
Code:
Private Sub Worksheet_Calculate()
Dim n As Long
n = GetTableSize() [B][COLOR=#008000]'GetTableSize monitors a static cell which calculates table number of used rows in a table. If that number is different than LastRowNumber...[/COLOR][/B]
If n > LastRowNumber Then NewDatabaseEntry [COLOR=#008000][B]' NewDatabaseEntry adds new records[/B][/COLOR]
[COLOR=#008000][B] ' Always set LastRowNumber so that even after entries are deleted (n < NumRows),[/B][/COLOR]
[COLOR=#008000][B] ' adding new entries will work correctly.[/B][/COLOR]
LastRowNumber = n [B][COLOR=#008000]'It then resets the values so they are equal again[/COLOR][/B]
End Sub
Sometimes, I'm working in the feeder table, and then I go check the records table and a new set of records has been added, even though no new rows were added.
Is there a way to add a message box that asks if you meant to add a new record and if you click no, it stops this from running?
Last edited: