I can't see how this would work. If the first character is D you extract
the leftmost five characters, which include the D. However, if ScanWO is
always six characters you could use the Right function:
If Asc(Left([ScanWO], 1)) >= 65 And _
Asc(Left([ScanWO], 1)) <=90 Then
WOnumber = Right([ScanWO], 5)
Else
WOnumber = [ScanWO]
End If
If the first character could be a lower case letter the code will need to be
expanded to accomodate that. See Help for more information about the Asc
function. Also see Help about the Chr function, which can be used to
determine the number to be used with the Asc function.
If the other option (other than an upper case letter) for the first
character is a number you could use:
If Asc(Left([ScanWO], 1)) >= 65 Then
WOnumber = Right([ScanWO], 5)
Else
WOnumber = [ScanWO]
End If
If there is a variable number of characters, none of the above will work
reliably. In that case you will need to provide more information about what
exactly you need to do.
BTW, in the future you should use the Subject line for just the subject of
the question. Post the question in the message body.
ldiaz said:
this code works perfect if the first digit is "D" but how I make it works
with any
letter, example from A to Z?
If Left([ScanWO], 1) = "D" Then
WOnumber = Left([ScanWO], 5)
Else
WOnumber = Left([ScanWO], 6)
End If
Thanks