+ Reply to Thread
Results 1 to 6 of 6

Delete data after the first six chars of a cell

  1. #1
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    Delete data after the first six chars of a cell

    Hi all, I am trying to delete anything after the first six characters in a cell.

    For example:

    134383922
    1012586790
    1752039458
    1293947
    13932881137

    As you can see, the numbers are of different lengths so i can't (seem) to use the function that takes a set amount OFF either the start or end (can't remember name of function).

    Basically the list above needs to come out as:

    134383
    101258
    175203
    129394
    139328

    Which is the the first six chars of any cell.

    I can do it by making the column width show only those chars but i wonder if theres a better way...

    Thanks as usual, in advance....

    Steve Quinn
    Woods of Morecambe Ltd
    www.woods-online.co.uk
    Last edited by woodsonline; 09-01-2009 at 03:56 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Delete data after the first six chars of a cell

    It's not clear if you want to overwrite the original values or have the six digit values populated in adjacent cell(s) via formulae, eg:

    B1: =0+LEFT(A1,6)
    copied down

    If you want to overwrite the original values then you're looking at VBA...

    Please Login or Register  to view this content.
    where original values reside in A1 onwards...
    Last edited by DonkeyOte; 08-30-2009 at 06:50 AM.

  3. #3
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    Re: Delete data after the first six chars of a cell

    excellent, thats perfect.

    It didnt matter actually whether to write over or into another cell, but in this case, the easier copy to another cell was best.

    by the way, not sure why, but

    =LEFT(A1,6)

    seemed to work a bit better because for some reason, your version

    =0+LEFT(A1,6)

    gave me strange results in the cell...

    Thanks again though, i thought there would be a perfectly simple way to do this...

    Steve.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Delete data after the first six chars of a cell

    The 0+ was used to coerce the 6 string value to a number... based on your sample values I had presumed all strings in A1 to be numeric (no leading zeroes) - using without the 0+ just means your results are numbers stored as text (the 0+ would fail if the values in A were not numeric).

  5. #5
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    Re: Delete data after the first six chars of a cell

    Thats great, thanks for answering, I really appreciate it.

    Regards

    Steve.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Delete data after the first six chars of a cell

    In that case, please make thread [solved]
    Never use Merged Cells in Excel

+ 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