Showing posts with label Macro to read character. Show all posts
Showing posts with label Macro to read character. Show all posts

Friday, February 22, 2013

Read every character in a string using excel VBA


This example reads every character in a string from left to right and returns the result in a message box. It makes use of the Mid function.
Sub LoopThroughString()

Dim LookInHere As String
Dim Counter As Integer

'Use your own text here
LookInHere = "AutomateExcel.com"

For Counter = 1 To Len(LookInHere)
    MsgBox Mid(LookInHere, Counter, 1)
Next

End Sub