Solved

Word VBA Delete last word from string

Posted on 2012-03-12
2
2,662 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

0
Comment
Question by:Fi69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
rowansmith earned 150 total points
ID: 37712964
MsgBox Left(Str,InStrRev(Str, " ") - 1)
0
 

Author Closing Comment

by:Fi69
ID: 37722886
Thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question