+ Reply to Thread
Results 1 to 30 of 30

Remove last 15 characters from all cells in a row...

  1. #1
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Remove last 15 characters from all cells in a row...

    Hello,

    i am a total newbie when it comes to excel so please be gentle.

    What I want to do is remove the last 15 characters from all cells within a column but keep the remaining 4. Let me explain further..

    the column contains the file name of an image, so I need to keep the .jpg/.gif/.png extension but remove the last 15 characters of the file name. Also there will be some clashes with some of the rows as there will be fewer than 15 characters to start with.

    I have bulk renamed all my images using the remove last 15 characters in the programme I have for this. Hence the reason i want to now copy it over to my spreadsheets.

    Thanks in advance
    Rob

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Remove last 15 characters from all cells in a row...

    Hi

    I don't understand exactly what you need, but you probably could do the trick using Data- Text to Columns ( perhaps with the "fixed width" option?)

  3. #3
    Registered User
    Join Date
    03-23-2005
    Posts
    4

    Re: Remove last 15 characters from all cells in a row...

    Provide a couple of examples.

  4. #4
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Ok.

    change
    file-name-of-image-fifteen-letter.jpg

    to
    file-name-of-image.jpg

    the second on has 15 characters removed but retains the file extension .jpg

    I assume if I just remove the last 15 characters it will remove the file extension too. Now i can't do a find and replace and simply remove all instances of .jpg/.gif/.png as I do not know which rows have .jpg etc There are 15,ooo rows to edit too.

    I hope this helps explain it better.

    Thanks
    Rob

  5. #5
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Remove last 15 characters from all cells in a row...

    Here is my array formula
    a little long, but hope other excel genuises will make shorter one

    =LEFT(A1,MATCH(SMALL(IF((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))>=65)*(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<=122)=0,"",ROW(INDIRECT("1:"&LEN(A1)))),15),IF((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))>=65)*(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<=122)=0,"",ROW(INDIRECT("1:"&LEN(A1)))),0))&RIGHT(A1,4)

    ctrl+shift+enter

    you can look to the file too

    Wanna say thank, Click Star
    Attached Files Attached Files
    Appreciate the help? CLICK *

  6. #6
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Remove last 15 characters from all cells in a row...

    Hi DaddyChan

    One way is the Replace function, assuming your data is in A1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  7. #7
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Remove last 15 characters from all cells in a row...

    Quote Originally Posted by Kevin UK View Post
    Hi DaddyChan

    One way is the Replace function, assuming your data is in A1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hi Kevin. Great solution. Especially interested because dont use Replace function oftenly. As I understand from your formula, it replaces middle 15 characters with nothing (""). But after testing your formula in other example, I realizied that if the number of characters after first 15 characters not equal to 15 then it gives wrong result.

  8. #8
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Quote Originally Posted by Kevin UK View Post
    Hi DaddyChan

    One way is the Replace function, assuming your data is in A1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks Kevin,

    I assume that will replace column A cell 1?
    or is it all of column A?

    Also how do i put that in?

    As I said total newbie to excel.. actually my first time using it

    Thanks
    Rob

  9. #9
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Here is a copy of the full column. I put it into column A as i can make changes and copy it over to the full spreadsheet after.

    Book1.xlsx

  10. #10
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    @AZ-XL

    Thank you, this looks like what i need. But not sure how to use this?

  11. #11
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Quote Originally Posted by AZ-XL View Post
    Here is my array formula
    a little long, but hope other excel genuises will make shorter one

    =LEFT(A1,MATCH(SMALL(IF((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))>=65)*(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<=122)=0,"",ROW(INDIRECT("1:"&LEN(A1)))),15),IF((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))>=65)*(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<=122)=0,"",ROW(INDIRECT("1:"&LEN(A1)))),0))&RIGHT(A1,4)

    ctrl+shift+enter

    you can look to the file too

    Wanna say thank, Click Star
    OK so I applied some logic to this code..

    i changed all instances of A1 to A3 as in the file you have A2 set up already.

    Do I just copy and paste the code to cell B3? or A3?

    Thanks

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Remove last 15 characters from all cells in a row...

    See the attached file for the solution.

    =REPLACE(A1,FIND(".???",A1)-15,15,"")

    I added also ISERROR to remove errors'.
    Attached Files Attached Files
    Last edited by oeldere; 04-13-2013 at 03:51 PM.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  13. #13
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Remove last 15 characters from all cells in a row...

    Uploading file again.

    My formula takes first 15 character from the left but doesnot count "-" sign. For example "AA-BB" word will be taken as four character.

    That is what I understood from your message. If I am wrong, then I am sorry
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Remove last 15 characters from all cells in a row...

    Hi

    I want to propose an alternative soln.

    Please Login or Register  to view this content.
    The above removes some of the text from the filename but the first No 4 in the formula

    Ensures that a minimum 4 characters of filename are kept.

    Change the 4 to whatever value you think is appropriate for you.

  15. #15
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Thank you so much fr the help so far.

    I have a cheeky question..

    is there a way to have the code in one column and then to save time, have a script to increase the A1 variable by in sequential order upto a value of say 15,00?

    I ask as I have 13,291 rows to edit and one at a time is going to take too long...

    Thanks in advance
    Rob

  16. #16
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Remove last 15 characters from all cells in a row...

    You can copy the formula down to the laste row.

    You can use a macro to do that for you.

  17. #17
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Hi thanks for the reply.

    What is a macro? and how do i use them/it?

    Thanks
    Rob

  18. #18
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Remove last 15 characters from all cells in a row...

    How about first solving your problem.

    After that we can help you with an macro.

    A macro (VBA) is a script that do the things automatic (after pushing a button), you do (normaly) manualy.

  19. #19
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Remove last 15 characters from all cells in a row...

    Rob

    Which formula are you using?

    Let me have a copy and I will write a macro to do the Job for you.

  20. #20
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Quote Originally Posted by mehmetcik View Post
    Rob

    Which formula are you using?

    Let me have a copy and I will write a macro to do the Job for you.
    Hi,

    I am using this in the header (row 1)

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    row 2 onwards I will use the following as it fixes any errors..

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I really got to get into the swing of excel.

    Thanks

  21. #21
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Hi all,

    i appreciate all the help so far thank you so much.

    I have just thought of a potential issue..

    How do i then copy the contents of the column with the new file names in over to my spreadsheet?

    here is a copy of the full spreadsheet and it it column N that needs to stay as the v_products_image but the content needs to be the edited (minus 15 characters long)

    Complete Full.csv

    The above URL is to the file I have on dropbox.

    Thanks
    Rob

  22. #22
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Remove last 15 characters from all cells in a row...

    Daddychan

    In your post #4:
    change
    file-name-of-image-fifteen-letter.jpg

    to
    file-name-of-image.jpg
    That is what the formula extracted.
    So with the file in post #21 is it 15 characters to the left of the, .jpg & .png in column N.
    Last edited by Kevin UK; 04-14-2013 at 04:12 AM.

  23. #23
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Remove last 15 characters from all cells in a row...

    Hi DaddyChan,

    This will do as you require but it could be tweaked to yield more satisfying results:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Press ALT + F11 to open the Visual Basic Editor.

    Open a macro-enabled Workbook or save your Workbook As Macro-Enabled

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    Last edited by xladept; 04-13-2013 at 08:16 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  24. #24
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Remove last 15 characters from all cells in a row...

    Hi Rob,

    I've been tweaking:

    Please Login or Register  to view this content.
    Last edited by xladept; 04-13-2013 at 11:10 PM.

  25. #25
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Remove last 15 characters from all cells in a row...

    Hi DaddyChan

    With reference to my post #22. Try the following formula in O2 (Or wherever you require the formula) and copy down.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Kevin UK; 04-14-2013 at 04:41 AM.

  26. #26
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Thank you so much for your help everyone.

    I saved my spreadsheet as macro enabled but can not open it in VBE.

    When I navigate through my computer I can see the file and it has a yellow ! . I think there was an error.

    Thanks
    Rob

  27. #27
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    OK I managed to get it to work.

    However, although i really do appreciate the work and effort you folks have put into this for me, there is an issue.

    I need it to remove the last 15 characters no matter what, but keep the extension (.jpg/.gif/.png).

    An example below..

    name of renamed image

    scanic-raygun-80r-.jpg

    same image renamed using the above code...

    scanic-raygun-80r.jpg

    Did you put in any special 'rules' to the code in post #24 ?

    Thanks
    Rob

  28. #28
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    Please don't kill me..

    I think it will save time, as i am time restricted, to rename them in numerical order.

    so start at

    15000

    and increase by 1 each time.

    Thanks
    Rob
    Last edited by DaddyChan; 04-15-2013 at 04:48 AM.

  29. #29
    Registered User
    Join Date
    04-13-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Remove last 15 characters from all cells in a row...

    hI all,

    Thanks to the power of youtube i found an easy way to use the concatenate function.

    Thank you all for your help.

  30. #30
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Remove last 15 characters from all cells in a row...

    Yeah,

    In post #24, I had the routine chop off at the next dash after 18 characters before I put the extension back on.

    Glad you've got it working - when you get the yellow, you could let us know what it says.

+ 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