+ Reply to Thread
Results 1 to 11 of 11

Multiple cells selected by user, than remove last character

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Multiple cells selected by user, than remove last character

    Hi!

    I would like to make a macro that remove the last character of all cells selected from my user IF they meet a certain condition.. let say they end by L.

    selectionrange.png

    Something like:

    Please Login or Register  to view this content.
    How can I do this ?

    Thanks,
    JP
    Last edited by JPGraphX; 06-06-2014 at 10:47 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Multiple cells selected by user, than remove last character

    I think you would have to loop.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    It's working. But it is converting it to Text. How may I change it back to number?

  4. #4
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    A simple click and enter is doing the job, but macro is better..

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Multiple cells selected by user, than remove last character

    Sorry, I don't understand.

    If the L was actually the text character L then the value in the cell would be text.

  6. #6
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    Well, that was my way to make sure you understand. (english is my second language and it is not always easy to explain what I mean to say)

    Real situation is:

    I have list of number and some finish by a chr(160), which is kind of equivalent to space bar.
    I need my macro to remove chr(160), if there is one, in all the cell selected by my user.

    But now, it is working very well with your macro. My only problem is that I want after that to format my selected number to X.XX (two digit after decimal). But I can't because it is text.
    Last edited by JPGraphX; 06-06-2014 at 12:00 PM.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Multiple cells selected by user, than remove last character

    If you want to remove Chr(160) use Replace.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    I still get the problem: Number stored as text

  9. #9
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    SOLVED:

    Selection.Replace Chr(160), ""
    With Selection
    Selection.NumberFormat = "0.00"
    .Value = .Value
    End With

    For Each cl In Selection.Cells
    cl.Value = cl.Value * 1

    Next cl

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Are the Chr(160) characters gone?

  11. #11
    Registered User
    Join Date
    08-06-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Multiple cells selected by user, than remove last character

    Yes it is gone!

+ 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] Need separate codes to remove first and last character from cells
    By alchavar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-01-2013, 04:48 PM
  2. how to remove a character from the middle of text on all cells
    By webuxer in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2013, 06:01 PM
  3. Replies: 3
    Last Post: 11-20-2012, 10:03 PM
  4. VBA to select user multiple selected ranges
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2010, 06:07 PM
  5. Remove character from excel cells
    By VMAMedia.com in forum Excel General
    Replies: 1
    Last Post: 01-21-2007, 10:37 PM

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