Excel- VBA Script – for adding a “0” in Excel.

For Danish users of Excel ™ it often happens that when pasting 10 digit social security numbers – an initial “0” may be lost.

Below is a simple solution- this VBA – checks if the number has 9 digits- if so it adds a “0” by using a & in front of the number

Function Addone(cprin As String)
Dim INS As String
If Len(cprin) = 9 Then
INS = “0”& cprin
Addone = INS
End If
Addone = INS
If Len(cprin) = 10 Then
INS = cprin
Addone = INS
End If
Addone = INS
End Function