Link to home
Start Free TrialLog in
Avatar of brothertruffle880
brothertruffle880Flag 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?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brothertruffle880

ASKER

Hi Rgonzo:
Does the plus sign connect with anything?  I'm getting red when I paste that into my VBE
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

brothertruffle880,
Have you missed off the end of Rgonzo's code?
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?
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.
Rgonzo.  It worked.  Thanks!