+ Reply to Thread
Results 1 to 3 of 3

VBA without error, but not running

  1. #1
    Registered User
    Join Date
    04-23-2013
    Location
    Jensen Beach, FL
    MS-Off Ver
    Excel 2016
    Posts
    41

    VBA without error, but not running

    Hi! I have (what I thought) was some pretty simple vba that I hobbled together from other posts, google searches, etc. It worked initially then stopped. Now I can't get it to work, but it isn't giving me an error so I can't tell where the problem is.

    This code (which is for a command button click on a multipage userform) should check Textbox2 value against the existing "Data" worksheet, and if the envelope number already exists display a message saying so. If it doesn't exist, it should check down all text boxes to make sure everything was filled out, then paste the answers to the "Data" worksheet, then clear the userform so they can enter another.

    Sometimes it will tell you that the envelope is already there, but if you change the envelope number and click it again, it does nothing (it should move on down the line, checking for answers, pasting the data, then clear the boxes). The only envelope number currently on my sheet is a test (numbered 1234) and if I type "12" in the textbox, it says the envelope is there (which it shouldn't).

    The other strange thing is that if I break this apart into sections, and for instance, use 3 command buttons (one to check the envelope number, one to paste the data, one to clear the data) they work. It is when I put them all together that they don't work.

    Any suggestions would be greatly appreciated. This is a very small part of a large multipage userform but it is integral to the project so I can't move ahead until I get it figured out.

    Thanks!
    spacle

    Please Login or Register  to view this content.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: VBA without error, but not running

    My suggestions are for error checking in general.

    At the top of your code, right after the DIM statements put something like this:
    Please Login or Register  to view this content.

    THEN just before End Sub (or End Function) Put this:

    Please Login or Register  to view this content.
    That should help catch the error - when the runtime error happens, your code will goTo the PROC_ERR: section and the message box will show you the description. (IF there is no error, it will reach exit sub and will not show you any message).

    Beyond that, have you set any break points to allow you to step through the code? To do that set a break at any line - when you run the code (make sure the project is unlocked or you won't get to see the code) - you will either: A-Reach the breakpoint meaning all is well up to that point, or B- will not reach that point and you will get the error message (from PROC_ERR section).

    THen you can just keep backing up the break point to see what happened (alternatively, if you do reach the break point - set another one farther down - or just press F8 to step through from there until it breaks ).
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA without error, but not running

    @spacle. GeneralDisarray's post is spot on. In addition, with just looking at your code and based upon your post you have a critical error.

    Please Login or Register  to view this content.
    How it is now, if a number doesn't exist you exit the subroutine. You stated you wanted to continue on checking the text boxes. Something like this is probably what you are looking for

    Please Login or Register  to view this content.
    Last edited by stnkynts; 08-04-2015 at 11:48 AM.
    If you are happy with my response please click the * in the lower left of my post.

+ 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] Error Occurs while running to On Error Goto Line3
    By moinsk21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2014, 02:37 PM
  2. 400 error running
    By excelV3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2013, 04:34 PM
  3. Error in running macro
    By ashahdeo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-11-2012, 08:55 AM
  4. Error While Running VBA
    By mohd_arastu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 12:48 PM
  5. Error '5' when running VBA for Pivot
    By Shaner73 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-18-2011, 02:14 PM
  6. Error 400 on running Macro
    By James T in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2006, 11:45 AM
  7. Error Running a Macro
    By viddom in forum Excel General
    Replies: 3
    Last Post: 07-28-2005, 09:05 AM

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