+ Reply to Thread
Results 1 to 5 of 5

Beginner If Then Help

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    Windber, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Beginner If Then Help

    Hi. I'm new to the boards and would like to see about getting some help.

    I'm writing a script to auto number a series of worksheets in the form of "Page xx of yy". Where xx is the current page and yy is the total number of pages. I have 2 main scripts doing this. My first script which is run as an addon is:

    Please Login or Register  to view this content.

    This works perfectly. My problem is in my script I use to select the proper cells. I have a check to be sure that the cells entered are actually cells. If they are not, it tells the user to make the corrections. If the cell is inserted incorrectly, the sub-routine runs through again, BUT, it goes back to the If Then statement where the error occurred and gives the user error again, even if the cells were entered correctly. I'm checking that the first character is a letter and the second character is a number. The Code I used for this is:

    Please Login or Register  to view this content.
    Yes, I know it's ugly, but I'm still learning how to program so I'm pretty much fudging my way through it. I have a few parts of the script disabled, as I was trying a few things, but nothing was working.

    Any help as to how to fix my program will be greatly appreciated.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Beginner If Then Help

    Try something like this...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    Windber, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Beginner If Then Help

    Ok, I like that. It looks that you are exiting the sub on an error instead of having the user re-enter the information into the form. That will fix my problem. I was just trying to avoid exiting the sub on an error.
    Thank you for the help.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Beginner If Then Help

    You're welcome. The user could not reenter the data while the sub is running.

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    Windber, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Beginner If Then Help

    Ok, That's probably where my error was coming from. I was trying to have them re-enter the data without exiting and restarting the sub.
    Thanks again.

+ 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