+ Reply to Thread
Results 1 to 7 of 7

Prevent User typing when Limit reached

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    Pasco, WA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Prevent User typing when Limit reached

    Hello
    I am new to the forum, but I am a seasoned user of Microsoft products.
    What I am trying to do is use the Data validation (this part is easy) to reach a certain amount of characters in a cell. Then instead of the warning message displaying, I would like a hard stop. So the user would be prevented from typing or copy and pasting more information in the cell then the data validation is allowed.

    I can find no thread that actually freezes or locks a cell when the data validation is reached.

    Please Login or Register  to view this content.
    I know that the And cell(cell reference is wrong and there is not a method or function for freeze. But hopefully this helps you understand what I am trying to do.
    Thanks
    Last edited by Cutter; 08-07-2012 at 02:50 PM. Reason: Added code tags

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Prevent User typing when Limit reached

    You can't do that in a cell; when Excel is in Edit mode, no VBA is running. You could use an ActiveX texbox control and test the length in its Change event.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    Pasco, WA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Prevent User typing when Limit reached

    Thank you. I had a feeling that was the case. But I was hoping.

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Prevent User typing when Limit reached

    @ wyscavern

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    Pasco, WA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Prevent User typing when Limit reached

    I was leaving it open...just in case someone else found a way. I have found some other information on Experts exchange that uses a truncate conditional formatting. If this does what I want it to I will post the answer and choose solved.
    Thank you.

  6. #6
    Registered User
    Join Date
    08-07-2012
    Location
    Pasco, WA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Prevent User typing when Limit reached

    I found some code that will actually truncate the characters in the cell. It does require the spreadsheet to be saved as a Macro enabled workbook.
    For current data, you can use this code to truncate:
    Open VBA (Alt+F11), point to Insert->Module and copy&paste the following code into this new module and run it by pressing F5.
    Please remember to change column reference in code (it is 1 = A column)

    Please Login or Register  to view this content.
    Truncating for new values :

    Goto VBA, Project Explorer (Ctrl + R), double click on the Thisworkbook object and copy and paste the following code into this module declaration section. Set the condition for your sheet and column (it is Column A - Target.Column = 1 and Sheet1 in code)

    Please Login or Register  to view this content.
    This seemed to work. So even though it does not stop, the user can only see up to 8 of the characters.
    Last edited by Cutter; 08-07-2012 at 07:49 PM. Reason: Added code tags

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Prevent User typing when Limit reached

    @ wyscavern

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

+ 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