Hi
I need a code for a macro to select every 3rd word after selection.
I need a code for a macro to select every 3rd word after selection.
Dim strTestString As String
Dim varSplit As Variant
Dim intCounter As Integer
Dim strBuild As String
strTestString = "She sells sea shells at the sea shore on a windy day"
varSplit = Split(strTestString, " ")
For intCounter = LBound(varSplit) To UBound(varSplit)
If (intCounter + 1) Mod 3 = 0 Then
strBuild = strBuild & " " & UCase(varSplit(intCounter))
Else
strBuild = strBuild & " " & varSplit(intCounter)
End If
Next
Debug.Print Trim(strBuild)
She sells SEA shells at THE sea shore ON a windy DAY
Comment