Hi Frayda,
Keith’s question is important: before changing the script, it would help to know what the FCConnect tab does.
That said, I think this can probably be simplified. Instead of trying to track row insertions and deletions one by one, I would recommend using a unique ID for each volunteer on the first sheet, then running one sync function that compares the current volunteer list with the visit log sheet.
Basic idea:
1. Keep a unique Volunteer ID in the first sheet.
2. In the visit sheet, also store that same ID, preferably in a hidden column.
3. When the sync runs:
- if an ID exists in sheet 1 but not in sheet 2, add a new row;
- if an ID exists in sheet 2 but no longer exists in sheet 1, delete that row;
- do not rely only on row numbers, because row numbers change when users sort, insert, or delete rows.
Apps Script has native methods like insertRowsAfter() and deleteRows() for this kind of operation, but I would avoid having many small trigger functions. A single sync function, run from an installable onEdit trigger or a custom menu, will likely be easier to maintain.
One important caution: if the second sheet contains historical visit records, deleting the whole row may also delete history. In that case, I would mark the volunteer as inactive instead of deleting their row.
If you can clarify what FCConnect contains, it will be easier to suggest the safest simplified structure.