+ Reply to Thread
Results 1 to 5 of 5

Cell cropping with a Macro or VB

Hybrid View

  1. #1
    Alastair79
    Guest

    Cell cropping with a Macro or VB

    I need to be able via a macro to copy only a portion of a cells contents to a
    different part of the sheet. What I have is like below:-

    "CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"

    I need to get ride of the "PBL" part and as you can see the first part of
    the cell varies in length. Is there any way to tell excel to copy till the
    space?

    Thanks............. Alastair.

  2. #2
    Don Guillett
    Guest

    Re: Cell cropping with a Macro or VB

    couldn't you just use edit>replace>PBL>""

    --
    Don Guillett
    SalesAid Software
    dguillett1@austin.rr.com
    "Alastair79" <Alastair79@discussions.microsoft.com> wrote in message
    news:1EB95589-B229-4C82-842A-64F707BAF590@microsoft.com...
    >I need to be able via a macro to copy only a portion of a cells contents to
    >a
    > different part of the sheet. What I have is like below:-
    >
    > "CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"
    >
    > I need to get ride of the "PBL" part and as you can see the first part of
    > the cell varies in length. Is there any way to tell excel to copy till the
    > space?
    >
    > Thanks............. Alastair.




  3. #3
    Tom Ogilvy
    Guest

    RE: Cell cropping with a Macro or VB

    iloc = Instr(1,activecell," ",vbTextcompare)
    s = left(activecell,iloc-1)
    activecell.offset(0,5).Value = s

    if the part to remove is always 3 characters and a space

    s = left(activecell,len(activecell)-4)
    activecell.offset(0,5).value = s

    --
    Regards,
    Tom Ogilvy


    "Alastair79" wrote:

    > I need to be able via a macro to copy only a portion of a cells contents to a
    > different part of the sheet. What I have is like below:-
    >
    > "CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"
    >
    > I need to get ride of the "PBL" part and as you can see the first part of
    > the cell varies in length. Is there any way to tell excel to copy till the
    > space?
    >
    > Thanks............. Alastair.


  4. #4
    Toppers
    Guest

    RE: Cell cropping with a Macro or VB

    If PBL is always at the end of the string and preceded by a blank:

    in B1 put:

    =LEFT(A1,LEN(A1)-4)


    and copy down.

    You can then copy (Col B)/pastespecial/values into col A.

    "Alastair79" wrote:

    > I need to be able via a macro to copy only a portion of a cells contents to a
    > different part of the sheet. What I have is like below:-
    >
    > "CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"
    >
    > I need to get ride of the "PBL" part and as you can see the first part of
    > the cell varies in length. Is there any way to tell excel to copy till the
    > space?
    >
    > Thanks............. Alastair.


  5. #5
    papou
    Guest

    Re: Cell cropping with a Macro or VB

    Hello
    No real need for a macro there but anyway:
    Either
    Left(Range("A1").Value, Len(Range("A1").Value) - 4)
    Or
    MID(Range("A1").Value),1,FIND("" "",Range("A1").Value,1)-1)

    will return the text without the " PBL" part.

    HTH
    Cordially
    Pascal


    "Alastair79" <Alastair79@discussions.microsoft.com> a écrit dans le message
    de news: 1EB95589-B229-4C82-842A-64F707BAF590@microsoft.com...
    >I need to be able via a macro to copy only a portion of a cells contents to
    >a
    > different part of the sheet. What I have is like below:-
    >
    > "CLOBMIDDLETON PBL" or "CLOBDIDCOT PBL"
    >
    > I need to get ride of the "PBL" part and as you can see the first part of
    > the cell varies in length. Is there any way to tell excel to copy till the
    > space?
    >
    > Thanks............. Alastair.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1