VBA: Loop Through a String
You can perform logic on, or return individual characters from a string in VBA by looping through the string.
The following is an example of looping through a string using a For…Next Loop, and returning each character in a msgbox.
Sub LoopThroughString()
Dim Counter As Integer
Dim MyString As String
MyString = "AutomateExcel" 'define string
For Counter = 1 To Len(MyString)
'do something to each character in string
'here we'll msgbox each character
MsgBox Mid(MyString, Counter, 1)
Next
End Sub
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
Get answers right away at our AE Excel Support Forums!



is there any way to output each character in individual cells of MS EXCEL instead of in a msg box??