+ Reply to Thread
Results 1 to 6 of 6

Selection Change working after second click on the cell. How to fix?

  1. #1
    Forum Contributor
    Join Date
    11-02-2016
    Location
    brasil
    MS-Off Ver
    office 365 2016 windows
    Posts
    195

    Selection Change working after second click on the cell. How to fix?

    Hi I have this code to format phone numbers. User types the whole number and when moves to another cell, the phone gets formatted.

    Numbers can have 10 or 11 digits. If I type 10 digits and click outside the cell... it gets formatted correctly.

    10 digitis 2233334444 > (22) 3333-4444

    If I go back to the cell and type 11 digits the format does not change, only after clicking outside the cell and clicking on it again.

    11 digits 22333334444 > (2) 233333-444 > click outside and click back corrects the format > (22) 33333-4444

    What should I add to the macro to fix this issue? Thank you

    Please Login or Register  to view this content.
    Last edited by 80Wil; 04-24-2017 at 12:34 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,986

    Re: Selection Change working after second click on the cell. How to fix?

    Use the Worksheet Change Event handler, not the Worksheet Selection Change Event handler.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,986

    Re: Selection Change working after second click on the cell. How to fix?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    11-02-2016
    Location
    brasil
    MS-Off Ver
    office 365 2016 windows
    Posts
    195

    Re: Selection Change working after second click on the cell. How to fix?

    Thank you! Worked!

    A question (Maybe I should open a new thread let me know... ) ok the number is formatted (22) 3333-4444, but in the formula bar appears 2233334444.
    This value will be sent to a table by VBA, how to send it formatted... something I can add to this macro I'm using to format it?
    Last edited by 80Wil; 04-24-2017 at 12:50 PM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,986

    Re: Selection Change working after second click on the cell. How to fix?

    Use the Format function with the Custom Format strings that you already have. In other words, don't just format it, convert it to a text string.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,986

    Re: Selection Change working after second click on the cell. How to fix?

    You're welcome. Thanks for the rep.

+ 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. Cell Selection based on user click
    By mohsinismail in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2014, 12:28 PM
  2. change value of cell by a click - 1 or 0
    By techexpressinc3 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-20-2013, 07:18 PM
  3. [SOLVED] Double Click Cell to go to Source not working
    By john60 in forum Excel General
    Replies: 5
    Last Post: 11-29-2012, 07:00 AM
  4. [SOLVED] Issue with cell selection on double click and returned value
    By Slyman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 07:16 PM
  5. Replies: 2
    Last Post: 08-03-2009, 04:34 PM
  6. Range Selection-When I click on a cell a form opens up?
    By GavinExcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2007, 07:35 AM
  7. Replies: 5
    Last Post: 08-18-2006, 05:05 AM
  8. Change from Column Selection to Cell Selection
    By Lil Pun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-16-2006, 06:15 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