+ Reply to Thread
Results 1 to 5 of 5

Need code to make completion of certain cells mandatory before saving file

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    Sligo, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need code to make completion of certain cells mandatory before saving file

    Hello, Thanks in advance for reading this and any help provided. I'm new to VBA so any help is appreciated!

    I need to make a form unable to be saved before all the required cells are filled in. It's for work and we've a problem with people sending in request missing required information.

    The required cells are: F10,G10,F11,F14,F15,F19,F20,F21,F22,F23,F24,F25,F26,F28,I28,F32,F35,F37,F40,F41,F42,F44,F45,I45,F46,F47

    Some of these are merged cells, would that make a difference to the code required? e.g. G10 is a merged cell made up of G10,H10 & I10.
    A number of cells contain drop down menus (F10,F24,F25,F42,F44,F45,I45,F46,F47) so would that matter?

    I have the code that works for cell G10 but don't know how to edit it properly to make it so all the other required cells are also checked. The sheet in question is called CCL.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need code to make completion of certain cells mandatory before saving file

    Here's an idea you can play around with. Put this formula in a cell off to the right... say M10.

    =IF(COUNTA(F10:I48)-COUNTIF(F10:I48, "*drop down*")=36, "DONE", "NOT DONE")

    Then have your BeforeSave macro check that cell, needs to say "DONE".
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Need code to make completion of certain cells mandatory before saving file

    I don't think it will make a difference with the merged cells or the dropdowns. Merged cells will report the value in the upper-left most cell, dropdowns record their value in the cell. You could do something like:

    Please Login or Register  to view this content.
    Define a Named Range "RangeLabels" that points to a range containing the cell identifier in the first column and its description in the second, like:

    F10 EmployeeNumber
    G10 Employee Name
    F11 Department
    F14 F14
    F15 F15
    F19 F19
    F20 F20
    F21 F21
    F22 F22
    F23 F23
    F24 F24
    F25 F25
    F26 F26
    F28 F28
    I28 I28
    F32 F32
    F35 F35
    F37 F37
    F40 F40
    F41 F41
    F42 F42
    F44 F44
    F45 F45
    I45 I45
    F46 F46
    F47 F47

  4. #4
    Registered User
    Join Date
    08-31-2012
    Location
    Sligo, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need code to make completion of certain cells mandatory before saving file

    Thanks JBeaucaire! I'll play around with this and see if I can get anywhere.

  5. #5
    Registered User
    Join Date
    08-31-2012
    Location
    Sligo, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need code to make completion of certain cells mandatory before saving file

    Thanks wallyeye! It's smarter to have a named range than to have to list all those cells. I'll try this and see how I get on.

+ 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