+ Reply to Thread
Results 1 to 6 of 6

Macro-Verify required fields before proceding with routine (save)

  1. #1
    Forum Contributor
    Join Date
    05-12-2009
    Location
    Hendersonville, TN
    MS-Off Ver
    Excel 2010
    Posts
    113

    Question Macro-Verify required fields before proceding with routine (save)

    Greetings,

    I am trying to get a macro that will check and stop (alert) for required cell incompleteness before running the rest of my macros. I found a workbook before_save macro, but it isn't working for me. Listed in the macro are the cells that are required on my worksheet that need to have a value other than " ". I would like this macro to run first after activating the command button I have my other macros attached to.

    Please Login or Register  to view this content.
    Another question is if I list the cells in a range ie B18:B21, and lets say B19 is missing, would it get overlooked if there was some value in the other parts of the range? I am looking for the macro to flag any cell listed that may be missing information.


    Here is where I order macro operations:

    Please Login or Register  to view this content.
    Thank you for any assistance or advice you may be able to provide.


    Patrick
    Last edited by pjbassdc; 02-13-2012 at 01:50 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro-Verify required fields before proceding with routine (save)

    Your first code is worksheet event code, you need to put it into a code module like your other procedures, then you call it as you do the others

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook. Don't upload a picture when you have a workbook question. None of us is inclined to recreate your data. Upload the workbook and manually add an 'after' situation so that we can see what you expect. In addition clearly explain how you get the results..
    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.
    To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.
    Last edited by royUK; 02-10-2012 at 12:14 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    05-12-2009
    Location
    Hendersonville, TN
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Macro-Verify required fields before proceding with routine (save)

    Thanks Roy,

    Attached is the form structure filled in with "dummy info" in the required locations that are minimally acceptable for a complete form. I have left out related worksheets that are used with the other macros since they are not part of my issue. Basically, I am just looking to have the macro flag and pause for anything that may be left blank in the cells I have completed in this example. I am not looking to check proper type or format, just that some value is present before the process carries forward and saves incomplete data to the other forms this one supplies with data.



    Patrick
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro-Verify required fields before proceding with routine (save)

    Start by selecting all the cells that must be filled in. Create a named Range called "CheckRange" to represent the selected cells. Then run this code from the button

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-12-2009
    Location
    Hendersonville, TN
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Macro-Verify required fields before proceding with routine (save)

    Thank you Roy. Your solution provided the stop gap I needed. I would however like to trigger a message box that alerts the user that the routine is halted, pending further input. Where in the above code can I make this happen?


    Patrick

  6. #6
    Forum Contributor
    Join Date
    05-12-2009
    Location
    Hendersonville, TN
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Macro-Verify required fields before proceding with routine (save)

    After tinkering around with it a bit, I did manage to get the message box functioning the way I wanted. Any that are interested, here is how it all turned out.

    Please Login or Register  to view this content.
    Patrick

+ 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