I am using dates as a sort of serial number for identification. There can be multiple items (up to 3) using the same date, so I have created a way to refine the serial numbers. I also allow for the occasional string to be entered instead of a date. :
So a first use of 6/30/2021 would generate a serial number of 44377.0, the next use of that date would be 44377.1, etc. Here's my potential problem: Say I have 3 items with the same date - 44377.0, 44377.1, and 44377.2. I delete 44377.1 (leaving only two items with the same date). The problem is that, if I want to add another item with that date, the code will see there are only 2 identical integers and assign the new item the serial number 44377.2, which already exists. I need a method to generate a unique serial number for this new item that would still leave the integer intact (as I use it for sorting).
For the record, I am using Excel 2010 on Windows 10.
VBA Code:
Dim datecheck As Integer
If IsNumeric(GigInfo.GigDate) Then
datecheck = Application.WorksheetFunction.CountIf(Rows(10), GigInfo.GigDate)
Range("D5") = Range("G10") + (0.1 * (datecheck - 1))
Else
datecheck = Application.WorksheetFunction.CountIf(Rows(10), 99999)
Range("D5") = 99999 + (0.1 * datecheck)
End If
So a first use of 6/30/2021 would generate a serial number of 44377.0, the next use of that date would be 44377.1, etc. Here's my potential problem: Say I have 3 items with the same date - 44377.0, 44377.1, and 44377.2. I delete 44377.1 (leaving only two items with the same date). The problem is that, if I want to add another item with that date, the code will see there are only 2 identical integers and assign the new item the serial number 44377.2, which already exists. I need a method to generate a unique serial number for this new item that would still leave the integer intact (as I use it for sorting).
For the record, I am using Excel 2010 on Windows 10.