VBE -Excel Function for extracting age from danish Social security number ( CPR number)

Public Function CPRAGE(InCPR As String, InpYear As String)
 Dim TAge As String
 Dim IAge As Integer
 Dim Placing As String
 Dim Pla As Integer
 Dim FinY As Integer
 'converting
 'extracting the right integers and converting integers into numbers
 'year of birth
 IAge = Mid(InCPR, 5, 2)
 TAge = CInt(IAge)
 'indicator of millenium of birth
 PlacingA = Mid(InCPR, 7, 4)
 Placing = CInt(PlacingA)
 'converting year string into integer
 FinY = CInt(InpYear)

If ((Placing >= 4000 And Placing <= 4999) And (TAge >= 0 And TAge <= 36)) Then
Pla = 2000
End If
 If ((Placing >= 4000 And Placing <= 4999) And (TAge >= 37 And TAge <= 99)) Then
Pla = 1900
End If
If ((Placing >= 5000 And Placing <= 5999) And (TAge >= 0 And TAge <= 57)) Then
Pla = 1900
End If
If ((Placing >= 1 And Placing <= 999) And (TAge >= 1 And TAge <= 150)) Then
Pla = 1900
End If
 If ((Placing >= 1000 And Placing <= 3999) And (TAge >= 1 And TAge <= 150)) Then
Pla = 1900
End If
If ((Placing >= 5000 And Placing <= 8999) And (TAge >= 0 And TAge <= 57)) Then
Pla = 2000
End If
CPRAGE = FinY - (Pla + TAge) 'Jorgen Hede -All rights reserved 2016 End Function