+ Reply to Thread
Results 1 to 9 of 9

macro to delete one character in a cell

  1. #1
    Registered User
    Join Date
    10-02-2007
    Posts
    5

    macro to delete one character in a cell

    I'm trying to use Excel 2003 macros for the first time and am very frustrated by it's recorder function. I've used several standalone TSR macro recorders several years ago and they were much easier but certainly not as feature rich.

    I have a spreadsheet that I've been using for a couple of years where I have manually entered data. My company has recently started to dump data into an Excel sheet but instead of pure numeric or date values being used they are extracting the values with the ' character starting the value. I want to strip this ' character.

    What I do is select the cell I want to edit and invoke the macro. Then press {F2} to edit the contents of the cell, {Home} to move to the left, {Del} to delete the first character - the apostrophe, and {Enter} to complete the edit and move down one cell.

    Using the recorder captures the following. Unfortunately it doesn't simply delete the first character, it copies the value of the previous cell to the next cell when I invoke the macro again.

    Please Login or Register  to view this content.
    It has to be easier than this, right?

    .

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Please Login or Register  to view this content.
    removes first character from selection

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-02-2007
    Posts
    5
    OK, this month's report is in.

    I edited the macro, removing the old code and inserting your suggestion. It deletes the first two characters.

    I start with.... '14182

    I want........... 14182

    I'm getting..... 4182

    ?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    And there was me thinking you were replying late to thank me ??

    I miss read your request to delete ' and the first character so try

    Please Login or Register  to view this content.
    VBA Noob

  5. #5
    Registered User
    Join Date
    10-02-2007
    Posts
    5
    Quote Originally Posted by VBA Noob

    Please Login or Register  to view this content.
    removes first character from selection

    VBA Noob
    If I change the 2 to a 1 it will remove the ' . Also, I tested this for your original and my edit as below, it does not go to the next cell below as I wanted as if using the {Enter} key to complete the edit.

    Please Login or Register  to view this content.
    ?

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    It works on the selected range

    VBA Noob

  7. #7
    Registered User
    Join Date
    10-02-2007
    Posts
    5
    LOL we're cross posting.

    The "Next cell" variable is not working.

    Maybe "NextCell"

    ??

  8. #8
    Registered User
    Join Date
    10-02-2007
    Posts
    5
    OMG! The "Selected" Range!!!! doh doh doh

    That is brilliant!! What a time saver.

    Thanks a million.


  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or

    Please Login or Register  to view this content.
    VBA Noob

+ 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