Showing posts with label Read string from left to right. Show all posts
Showing posts with label Read string from left to right. Show all posts

Friday, February 22, 2013

Read every word in a string using excel VBA


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

Dim LookInHere As String
Dim Counter As Integer
Dim SplitCatcher As Variant

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

SplitCatcher = Split(LookInHere, " ")

For Counter = 0 To UBound(SplitCatcher)
    MsgBox SplitCatcher(Counter)
Next

End Sub