I want to have / define a unique identifier for each row of data in an Excel data sheet, so that I can use it when transferring data forward, and it stays the same when rows are added / deleted above it.
My thoughts is to use the ID Range attribute ( msdn link )
So, I have a user-defined function (UDF) that I put on every line that gets / sets the identifier as follows:
Dim gNextUniqueId As Integer
Public Function rbGetId(ticker As String)
On Error GoTo rbGetId_Error
Dim currCell As Range
'tried using Application.Caller direct, but gives same error
Set currCell = Range(Application.Caller.Address)
If currCell.id = "" Then
gNextUniqueId = gNextUniqueId + 1
'this line fails no matter what value I set it to.
currCell.id = Str(gNextUniqueId)
End If
rbGetId = ticker & currCell.id
Exit Function
rbGetId_Error:
rbGetId = "!ERROR:" & Err.Description
End Function
But this fails in the line specified in
"User Defined or Object Error"
I thought maybe this is one of these UDF limitations, but I also get the same error if I try it from code run using the ribbon button ...
, - , , / ...
EDIT:
Ant, , . ... "Protect UserInterFaceOnly: = True", . " ", , , - Protect AutoOpen, UserInterfaceOnly...
, / - , UDF... , , , - ActiveSheet.unprotect, ActiveWorkbook.unprotect: (
.