+ Reply to Thread
Results 1 to 3 of 3

Mandatory cells

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    Dammam, KSA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Mandatory cells

    Hi, am very new to excel and need to make cells C2, D3, E3, D4,E4, D5, E5,D6, E6, D7, E7, D8, E8, D9, E9, D10, E10, D11, E11, D12 & E12 mandatory in an open sheet.
    please help to stop closing the sheet before all these cells are filled. you may reach me at "[email protected]"

  2. #2
    Valued Forum Contributor jj72uk's Avatar
    Join Date
    03-22-2008
    Location
    Essex, England
    MS-Off Ver
    Work - Office 2000, Home - Office 2007E
    Posts
    360

    Re: Mandatory cells

    So just to confirm.

    You want the above listed cells filled before the excel sheet is allowed to close?

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Mandatory cells

    Try this code in the workbook_beforeclose module.

    Keep in mind that users have the option to NOT enable macros when prompted and can thus defeat any VBA code.

    Option Explicit
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
        Dim msg As String
        
        msg = "Warning: cells C2 and D3:E12 are missing data"
        msg = msg & vbLf & vbLf & "Please complete the missing entries"
        
        With Sheet1
            If .Range("C2") = vbNullString Or WorksheetFunction.CountBlank(.Range("D3:E12")) > 0 Then
                MsgBox (msg), vbCritical
                Cancel = True
            End If
            Application.Goto reference:=Sheet1.Range("C2"), scroll:=True
        End With
    
    End Sub
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ 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