sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
I have a column that is set up as a pattern that includes the current year, a dash, and the next sequential 4 digit number. When I run the code to insert my new row at the bottom of the table, I want this code to look at the cell directly above in column A and just bring down the last 4 digits +1. Out in front each time, I need the current 4 digit year, a dash and finally that sequential part of the entry above.
If the last entry on the list is 2022-0234, I need the current year to come down for the next entry and the next sequential number of the last 4 digits like this when I select the add new row to table button:
2022-0235
If I'm on the last day of the year (December 31st) when the last entry was added and it looked like this:
2022-0843, then I want it to start the sequence over again on January 1st with 2023-0001.
I have no idea where to begin with all of this. All I have is a simple code that adds the next blank row.
Sub AddNewJobToJobList()
Range("A" & Rows.Count).End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert
End Sub
If the last entry on the list is 2022-0234, I need the current year to come down for the next entry and the next sequential number of the last 4 digits like this when I select the add new row to table button:
2022-0235
If I'm on the last day of the year (December 31st) when the last entry was added and it looked like this:
2022-0843, then I want it to start the sequence over again on January 1st with 2023-0001.
I have no idea where to begin with all of this. All I have is a simple code that adds the next blank row.
Sub AddNewJobToJobList()
Range("A" & Rows.Count).End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert
End Sub