tags:

views:

38

answers:

2
sub main()   

'''some more code'''

For j = InStr(1, stext, " ") To Len(stext)
        If IsNumeric(Mid(stext, j, 1)) Or IsAlpha(Mid(stext, j, 1)) Then
            letter1 = Mid(stext, j, Len(stext))
            Exit For
        End If
    Next j

'''some more code'''

end sub

i am walking through line by line.

as soon as the macro gets to this line:

If IsNumeric(Mid(stext, j, 1)) Or IsAlpha(Mid(stext, j, 1)) Then

it escapes the entire sub!

does anyone know what i am doing wrong?

+3  A: 

This typically happens when you have an error. In this case, it could be an out of bounds error. You could have a space at the end of stext, which would cause this problem.

Jeff Schumacher
its escaping the for loop on the first try
I__
put On Error Goto 0 statement before For loop, and it will show you an error
volody
Could be IsAlpha, I don't think that's a build in VBA function.
Jeff Schumacher
+1  A: 

I think this might help.

ISALPHA, ISNUMERIC? - Microsoft Access / VBA Answers

Jacob