melewie
Board Regular
- Joined
- Nov 21, 2008
- Messages
- 188
- Office Version
- 365
- Platform
- Windows
Hi All,
I am having problems (again!!!). I am trying to idenify the first lower case letter in a string. Below is the cloest I have got (It doesnt work at all but doesnt debug)
Any help would be great, thanks in advance
I am having problems (again!!!). I am trying to idenify the first lower case letter in a string. Below is the cloest I have got (It doesnt work at all but doesnt debug)
Code:
[SIZE=2]Option Explicit
Sub Test1()
Dim StrLen As Integer
Dim ChrNum As Integer
Dim i As Integer
Dim j As Integer
Dim Exitfor As Boolean
Dim str As String
[COLOR=black][FONT=Verdana]StrLen = Len(Selection)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]str = Selection.Value<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]For i = 1 To StrLen<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Exitfor = False<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]For j = 97 To 122<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If InStr(i, str, Chr(j), vbBinaryCompare) = 1 Then<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Exitfor = True<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Exit For<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Else<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]MsgBox Chr(j)<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End If<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Next j<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If Exitfor = True Then Exit For<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Next i<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]MsgBox i<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End Sub[/FONT][/COLOR]
[/SIZE]
Any help would be great, thanks in advance