How to separate words from a string

Publicado em: 15 Abril 2020
no canal de: Learn Excel VBA Macros
34
3

Separate Words (First Name and Last Name ) from a string

You can use below VBA Macro for this task.

Sub SeparateStrings()
Dim ws As Worksheet
Dim StrName As String
Dim i As Integer
Dim Lrow As Long
Dim intComma As Integer

Set ws = ThisWorkbook.ActiveSheet

Lrow = ws.Range("A" & Rows.Count).End(xlUp).Row

For i = 4 To Lrow
StrName = ws.Cells(i, 1).Value
intComma = InStr(StrName, ",") ' this will find Comma location in string

With ws
.Cells(i, 2).Value = Mid(StrName, intComma + 2)
.Cells(i, 3).Value = Left(StrName, intComma - 1)
End With

Next i

End Sub


Nesta página do site você pode assistir ao vídeo on-line How to separate words from a string duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Learn Excel VBA Macros 15 Abril 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 34 vezes e gostou 3 espectadores. Boa visualização!