I want to check for digit (1,2,3,4,5,6,7,8,9,0) and hyphen (-) in vba.
Right now I am using this statement
For i = Len(ActiveCell.Value) To 1 Step -1
cch = Mid(ActiveCell.Value, i, 1)
If cch = "1" Or cch = "2" Or cch = "3" Or cch = "4" Or cch = "5" Or _
cch = "6" Or cch = "7" Or cch = "8" Or cch = "9" Or cch = "-" _
Or cch = "0" Then
else
MY_FUNCTION
endif
I want to shorten it
So, the cell should contain only combination of these characters.
The above statement checks all chacaracters one by one.
I used backward loop from my previouse statement so didn't changed it right now.