Avatar of brothertruffle880
brothertruffle880
Flag for United States of America asked on

Word VBA

I have a string of text.  Somewhere in that string there's a < (greater than character ).  I would like to delete everthing from my current cursor position to the greater than character.
 My cursor is at the beginning of the line
 What is the VBA code to do this?
Microsoft WordVB ScriptVisual Basic.NETVBA

Avatar of undefined
Last Comment
brothertruffle880

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
brothertruffle880

ASKER
Hi Rgonzo:
Does the plus sign connect with anything?  I'm getting red when I paste that into my VBE
GrahamSkan

I think this should do it:
Sub DelTillGT()
    Dim rng As Range
    
    Set rng = Selection.Range.Duplicate
    
    rng.End = ActiveDocument.Range.End
    With rng.Find
        .Text = "*\>"
        .MatchWildcards = True
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceOne
    End With
End Sub

Open in new window

GrahamSkan

brothertruffle880,
Have you missed off the end of Rgonzo's code?
Your help has saved me hundreds of hours of internet surfing.
fblack61
brothertruffle880

ASKER
Here's an example of what I want (apologies for earllier typo.  I should have said LESS THAN sign, not GREATER THAN
Candy Apple < Needed text1
Chocolate Apple < needed text2
Vanilla Apple < needed text3
At the end of the process, I want to have the following:
needed text1
needed text2
needed text3
I want everything deleted from the beginning of each line up to the less than sign.

I have a string of text.  Somewhere in that string there's a < (less than character ).  I would like to delete everthing from my current cursor position to the greater than character.
  My cursor is at the beginning of the line
  What is the VBA code to do this?
brothertruffle880

ASKER
Holy cow Rgonzo!   Your posting corrected itself.
Now I see the entire thing!  
A few minutes ago there was a dangling plus sign at te end of the code.  
Let me try the clean post I just saw.
brothertruffle880

ASKER
Rgonzo.  It worked.  Thanks!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.