Hey guys.
I can't figure out what is causing the error in this code.
Code:
Public Function NewCode(ByVal EmpCode As String) As Variant
Dim nums As String
Dim lefttwo As String
Dim rightthree As String
Dim newlet As String
nums = "0" & Left(Mid(EmpCode, 3), 4)
lefttwo = Left(nums, 2)
rightthree = Right(nums, 3)
newlet = DLookup("Letter", "NumToAlpha", "Number = '" & lefttwo & "'")
NewCode = newlet & rightthree
End Function
I added the ByVal because I was getting a ByRef argument type mismatch when I would call the function.
This function takes RL71730, drops the RL and the last 0, adds a 0 at the beginning, and converts the 07 to a letter from the table, and concatenates that letter with the last 3 digits. Final result: H173.