Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bonni Garcia   on Nov 10 In MS Office Category.

  
Question Answered By: Fadwa Ahmed   on Nov 10

Another option is to use a function to find where the alphabetic
characters begin and end within the string. The advantages are the
method is available for use by persons with no real programming ability.




(The direction input simply tells the function whether you're looking
for the first alphabetic character from the default left [1 or any
character other than 2] or the first alphabetic character from the right
[2]





Function FirstLetter(cell As String, Direction As Double)

Dim character() As String

Dim s As Integer, i As Integer



s = Len(cell)

ReDim character(1 To s) As String



If Direction = 2 Then

For i = s To 0 Step -1

character(i) = Mid(cell, i, 1)

If Asc(character(i)) < 48 Or Asc(character(i)) > 57 Then

GoTo EndLoop

End If

Next i

Else

For i = 1 To s

character(i) = Mid(cell, i, 1)

If Asc(character(i)) < 48 Or Asc(character(i)) > 57 Then

GoTo EndLoop

End If

Next i

End If

EndLoop:



FirstLetter = i



End Function

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on loop through a range name Or get search suggestion and latest updates.


Tagged: