View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default How do I use VBA or a function to do a certain type of string work

One way:

Public Function FirstAlphaNumeric(ByVal Text) As String
Dim sTemp As String
Dim sResult As String
Dim i As Long
sTemp = UCase(Text)
If sTemp Like "*[0-9,A-Z]*" Then
For i = 1 To Len(sTemp)
sResult = Mid(sTemp, i, 1)
If sResult Like "[0-9,A-Z]" Then Exit For
Next i
End If
FirstAlphaNumeric = sResult
End Function



In article ,
christopher ward wrote:

i have a simple spreadsheet of

christopher ward in cell A1
'''''''''''''''''brian wild in cell a2
####jane brown in cell a3
;;;;8888 in cell a4

I now need a VBA function or VBA code Macro that works out in each cell
where the first alphanumeric character falls and returns the character.The
length of the string is not fixed and will have various characters which are
not a-z or 1-9 which are the ones I am interested in.

If you reply to this post thanks in advance it is appreciated

so my answers would be

c
b
j
8


thanks