jwahome2002
New Member
- Joined
- Nov 10, 2016
- Messages
- 6
Hello. I have been struggling for the past week to find a way in VBA to autonumber an ID field in an Excel table when a new row is inserted. I want to avoid using a cell formula (which I can do) as there risks with that solution. I have a table with fields "TaskID", "Task","Resource". The ID field is simply a numerical field and the ID only needs to be set to the next value (e.g. last ID = 2, the next value would be 3).
So every time a new record is created (usually by tabbing from the last field of the last row), the ID is generated through the VBA sub.
I have tried several solutions. Some got me close, but required the "Task" field to be updated before the ID would be set. Another attempt created the IDs, but did so when any cell in the row was touched - including the headers. I thought this would be an easier task, but I cannot seem to find anything that works. Any help is greatly appreciated!! Thanks!!!
So every time a new record is created (usually by tabbing from the last field of the last row), the ID is generated through the VBA sub.
I have tried several solutions. Some got me close, but required the "Task" field to be updated before the ID would be set. Another attempt created the IDs, but did so when any cell in the row was touched - including the headers. I thought this would be an easier task, but I cannot seem to find anything that works. Any help is greatly appreciated!! Thanks!!!