Consulting

Results 1 to 3 of 3

Thread: Deleting words in a string

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Posts
    48
    Location

    Deleting words in a string

    Hi Guys

    I have 2 sets of security IDs. One includes a Bloomberg 'yellow key' and one does not.

    so for example

    ERZ9 vs ERZ9 Comdty
    or Z Z9 Index

    I am trying to think of a way of taking the yellow key (Comdty, Index, Crncy) out of the data.

    essentially i want to locate the last space in the string and delete right of that space.

    Any ideas?

    sorry guys not sure on this one

    thanks in advance for the help

    JZB

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub TrimLast()
    Dim Cel
    For Each Cel In Selection
    Cel.Value = Left(Cel, InStrRev(Cel, " ") - 1)
    Next
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Mar 2009
    Posts
    48
    Location
    that works a treat. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •