+ Reply to Thread
Results 1 to 6 of 6

Need Resume and ErrorHandler added to working code

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Post Need Resume and ErrorHandler added to working code

    I have created a sub to check the length of text strings in a range of cells and ask the user what length they want the text trimmed to. (It's used for reducing text that you need to enter into non-Excel programs that have a character limit on the input fields).

    However I don't have any error handler to deal with a non valid number in the Input Box response.

    Could someone please give me the code corrections? (In the code I have commented where I want the Error Handler check and what I need it to check for along with some tentative ideas).

    Please Login or Register  to view this content.
    Last edited by mc84excel; 02-28-2013 at 07:21 PM. Reason: Typo + reword for clarification
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need Resume and ErrorHandler added to working code

    Maybe this will help. Type:=1 will only allow numbers

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Need Resume and ErrorHandler added to working code

    Quote Originally Posted by mike7952 View Post
    Maybe this will help. Type:=1 will only allow numbers
    Hey thanks. That enforces the numbers only

    Any tips on the rest? (How to Error/Resume if user enters negative numbers or if user enters a number higher than the cell len?)

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Need Resume and ErrorHandler added to working code

    Solved it. Am posting code below (should anyone else have a use for it). (BTW the first line is commented because it's referring to a project module which isn't included with the code posted below).

    One thing I would like to add to it (but not sure if can pull it off) is to make the Cancel button on the InputBox have the effect of a sub exit (so user has the option to abort at any point during the procedure).

    Please Login or Register  to view this content.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need Resume and ErrorHandler added to working code

    Like this maybe

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Need Resume and ErrorHandler added to working code

    Quote Originally Posted by mike7952 View Post
    Like this maybe

    Please Login or Register  to view this content.
    It was that simple! (Slaps forehead). Thanks Mike.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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