+ Reply to Thread
Results 1 to 11 of 11

Remove first 5 characters from a cell

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    Myrtleford, Australia
    MS-Off Ver
    Excel 2013
    Posts
    25

    Remove first 5 characters from a cell

    Hi,
    I have attached a spread sheet with some code I recoded with macro recorder.
    I have been searching for some extra code to insert in the middle of the recorded code which will remove the first 5 characters from the active cell and past the result to the next page.
    I have seen a lot of relevant code but havnt been able to get any to work in my code.


    Please Login or Register  to view this content.

    I am using Windows7 with Excel 2013.

    I would appreciate some help with this.

    Thank you,
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Remove first 5 characters from a cell

    Hi, PeterR,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Remove first 5 characters from a cell

    To Sheet1 code module
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-26-2012
    Location
    Myrtleford, Australia
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Remove first 5 characters from a cell

    Hello Holger and Jindon,
    thank you for your replies.

    After checking out both of your code I realised I made a mistake in my problem description so I am really sorry about that.

    I only want to modify one cell at the time and this will be determined by the position of the cursor - and the result is to be pasted into the same cell each time - CellA2 on Sheet2

    Jindon even though I made the mistake you still understood what I needed to do and your code pastes to the correct cell but I cant get the 5 first characters to delete?

    Holger, your code deletes the first 5 characters perfectly but I cant just select one particular cell to modify.

    Thanks to both of you for your efforts, I really appreciate it.
    Peter

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Remove first 5 characters from a cell

    Quote Originally Posted by PeterR View Post

    Jindon even though I made the mistake you still understood what I needed to do and your code pastes to the correct cell but I cant get the 5 first characters to delete?
    What do you mean?

    You said in the sheet2
    When the cursor is placed in cellA1 of Sheet1 and the code is run then CellA2 and CellB2 on Sheet2 will contain the value 95
    The code should do it.

  6. #6
    Registered User
    Join Date
    11-26-2012
    Location
    Myrtleford, Australia
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Remove first 5 characters from a cell

    Hi Jindon,

    I have attached a screen shot of the result when I run the code.
    I am not sure how to get it to delete the first 5 characters - maybe I am doing something wrong?

    Regards,
    Peter
    Attached Images Attached Images

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Remove first 5 characters from a cell

    Have you tried my attach file?

    Whenever you click on a cell in A1:A10 on Sheet1, Sheet2!A2:B2 should have numbers.

  8. #8
    Registered User
    Join Date
    11-26-2012
    Location
    Myrtleford, Australia
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Remove first 5 characters from a cell

    Hi Jindon, I see how it works now – your code is very smart - I am sorry I didn’t know that could be done with VBA.
    I still have a problem - my spreadsheet has quite a few cells spread around Sheet1 which need to be copied to positions on Sheet2 with the first 5 characters deleted.
    I was hoping to have some code inserted in the middle of my original recorded code -
    Please Login or Register  to view this content.
    I don’t know much VBA so my plan was to make copies of this code and paste them into one routine one after the other then change the cell addresses in each copy to match all of the movements I need to make.
    I know this is probably not very efficient but it is something I can work with.
    Do you think this is possible?
    Regards,
    Peter

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Remove first 5 characters from a cell

    Is this the one you want?
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-26-2012
    Location
    Myrtleford, Australia
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Remove first 5 characters from a cell

    Hi Jindon,
    YES, YES! it works - thank you so much, it was starting to stress me out.

    Really appreciate your help and patience, thank you.
    Peter

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Remove first 5 characters from a cell

    No problem.

    Can you mark this thread as "Solved"?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Remove certain characters from a cell
    By M8R-l3mfmi in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-03-2013, 05:15 PM
  2. remove everything but the last three characters at the end of the cell?
    By Rabbitstew in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-21-2012, 09:24 AM
  3. [SOLVED] Remove Characters from a cell
    By Kim in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-01-2006, 12:21 PM
  4. [SOLVED] How to remove characters from a cell
    By Jonathan Dunne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2005, 07:05 AM
  5. remove last three characters of cell
    By mira in forum Excel General
    Replies: 8
    Last Post: 07-27-2005, 08:05 PM

Tags for this Thread

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