Is there a way to assign a unique key to records, after they have been sorted? I have code that currently reads the value of a cell in the last row and adds 1 to it. The issue is, I have to sort the same sheet, which will inevitably cause the numbers to become non-sequential. I was thinking it may have something to do with a MAX function, but I'm not seeing anything on this forum or google, that guides me there. Thoughts? Here is what I have so far:
Code:
If ws1.Range("D2") = "" Then Me.txt_Key = "1"
Else
Me.txt_Key = ws1.Range("D" & LastRow - 1).Value + 1
End If