Function to return type of data in string
* Blank []
* Numeric [0152]
* Alpha [Good Boy]
* Mixed [Good0152]
Function IdentifyStringType(vMyInput As Variant) As String
Dim iLoop As Long, iLenPre As Long, iLenPost As Long, sTemp As String
'Load the string and take a snapshot of the length
sTemp = vMyInput
iLenPre = Len(sTemp)
'Skip the review process for 0 length strings
If iLenPre = 0 Then GoTo gNoString
'Loop through all 10 digits and remove them from the string
For iLoop = 0 To 9
sTemp = Replace(sTemp, iLoop, "", , , vbTextCompare)
Next iLoop
'Take a snapshot of the length AFTER replacement of numeric values
iLenPost = Len(sTemp)
'Mark "Numeric" if there are no Alpha Characters
If iLenPost = 0 Then GoTo gAllNumbers
'Mark "Alpha" if there are no Numeric Characters
If iLenPre = iLenPost Then GoTo gAllAlpha
'If it gets this far, the string is a mix of ALPHA + NUMERIC
GoTo gMixed
'------------------------------------------------------------------------
gNoString:
IdentifyStringType = "Blank"
Exit Function
'------------------------------------------------------------------------
gAllNumbers:
IdentifyStringType = "Numeric"
Exit Function
'------------------------------------------------------------------------
gAllAlpha:
IdentifyStringType = "Alpha"
Exit Function
'------------------------------------------------------------------------
gMixed:
IdentifyStringType = "Mixed"
Exit Function
'------------------------------------------------------------------------
End Function
Dim iLoop As Long, iLenPre As Long, iLenPost As Long, sTemp As String
'Load the string and take a snapshot of the length
sTemp = vMyInput
iLenPre = Len(sTemp)
'Skip the review process for 0 length strings
If iLenPre = 0 Then GoTo gNoString
'Loop through all 10 digits and remove them from the string
For iLoop = 0 To 9
sTemp = Replace(sTemp, iLoop, "", , , vbTextCompare)
Next iLoop
'Take a snapshot of the length AFTER replacement of numeric values
iLenPost = Len(sTemp)
'Mark "Numeric" if there are no Alpha Characters
If iLenPost = 0 Then GoTo gAllNumbers
'Mark "Alpha" if there are no Numeric Characters
If iLenPre = iLenPost Then GoTo gAllAlpha
'If it gets this far, the string is a mix of ALPHA + NUMERIC
GoTo gMixed
'------------------------------------------------------------------------
gNoString:
IdentifyStringType = "Blank"
Exit Function
'------------------------------------------------------------------------
gAllNumbers:
IdentifyStringType = "Numeric"
Exit Function
'------------------------------------------------------------------------
gAllAlpha:
IdentifyStringType = "Alpha"
Exit Function
'------------------------------------------------------------------------
gMixed:
IdentifyStringType = "Mixed"
Exit Function
'------------------------------------------------------------------------
End Function