Hey all,
This function will allow only the alphanumeric characters when applied to a cell. However with new workbooks all goes well but with my old workbook the very function will cause the workbook to prompt user to save file, even though no changes are made to it. This can be a little annoying and I would like to make it go away. It is very clear that the function is causing this problem as removing it fixes the issue.
Will appreicate a lot.
Thanks.
This function will allow only the alphanumeric characters when applied to a cell. However with new workbooks all goes well but with my old workbook the very function will cause the workbook to prompt user to save file, even though no changes are made to it. This can be a little annoying and I would like to make it go away. It is very clear that the function is causing this problem as removing it fixes the issue.
VBA Code:
Function AlphaNumericOnly(strSource As String) As String
Dim i As Integer
Dim strResult As String
For i = 1 To Len(strSource)
Select Case Asc(Mid(strSource, i, 1))
Case 48 To 57, 65 To 90, 97 To 122: 'include 32 if you want to include space
strResult = strResult & Mid(strSource, i, 1)
End Select
Next
AlphaNumericOnly = strResult
End Function
Will appreicate a lot.
Thanks.