We help IT Professionals succeed at work.

Word VBA Delete last word from string

Medium Priority
3,958 Views
Last Modified: 2012-03-14
Hi experts

I need to delete the last word from my string.

I have the code below that tells me the last word in the string, but I can't work out how to manipulate it so that I end up with my string equalling "The quick brown" rather than "The quick brown fox.

Dim Str As String
Str = "The quick brown fox"
MsgBox Right(Str, Len(Str) - (InStrRev(Str, " ") - 1))

Open in new window

Comment
Watch Question

MsgBox Left(Str,InStrRev(Str, " ") - 1)

Author

Commented:
Thank you!