+ Reply to Thread
Results 1 to 7 of 7

Prevent Printing Unless Drop Down Menu is used

  1. #1
    Registered User
    Join Date
    04-15-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    4

    Prevent Printing Unless Drop Down Menu is used

    I am trying to prevent someone from printing an excel form unless they have filled in all the necessary fields.
    The part I am stuck on is with drop down menu's I do not know how it reads the return.

    Private Sub Workbook_BeforePrint(Cancel As Boolean)

    Dim oCell As Range
    Dim NoBlanks As Range

    Set NoBlanks = ActiveSheet.Range("c15")

    For Each oCell In NoBlanks
    If oCell.Value = "" Then
    Cancel = True
    MsgBox "Not all required cells have been filled", vbCritical + vbOKOnly, "Error"
    Exit Sub
    End If
    Next

    End Sub

    That's my Code I've also tried
    If oCell.Value = "Select Action Required From Drop Down" Then

    As the statement Select Action Required From Drop Down is the default statement in that drop down menu (not blank). Neither restricts printing.
    C15 is the cell in which the drop down menu is located.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Prevent Printing Unless Drop Down Menu is used

    The term "drop-down menu" is ambiguous - does the cell have a Data Validation List, or is it linked to a Listbox?

    For troubleshooting / development, just show what the value currently is, using

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-15-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    4

    Re: Prevent Printing Unless Drop Down Menu is used

    Thanks for the help Bernie, I'm still not getting it.
    It is a Listbox that I am using

    I'm not sure what your line
    If MsgBox("The current value is """ & NoBlanks.Value & """ - Continue?", vbYesNo) = vbNo Then Exit Sub
    does,

    The Listbox calls on 3 options (from Sheet6)
    Selection Action Required from Drop Down (Default)
    Request JTP
    Remove JTP

    my objective is ban printing if "Selection Action Required from Drop Down" is still selected
    but to allow printing if Request JTP or Remove JTP is selected

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Prevent Printing Unless Drop Down Menu is used

    This assumes that you have linked the listbox to cell C15 of the sheet that you want to print:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-15-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    4

    Re: Prevent Printing Unless Drop Down Menu is used

    c15.PNG
    Listbox.PNG
    Sheet6.PNG

    Above are snips on my file.
    The code you sent unfortunately did not work. I can print in all situations. I can't quite interpret the code you've written so I'm not really sure where the logic is failing.

    I really do appreciate the help!

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Prevent Printing Unless Drop Down Menu is used

    Are you putting the code into the codemodule of the ThisWorkbook object?

    Do you have a data validation list (it seems that you do) and not a listbox?

    If so, try this version

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-15-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    4

    Re: Prevent Printing Unless Drop Down Menu is used

    Yes that Worked!
    Thank-you

+ 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. Resetting a drop down menu by selecting another drop down menu
    By Chris07 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2013, 11:57 AM
  2. Replies: 1
    Last Post: 02-07-2013, 11:03 AM
  3. [SOLVED] I cant work out how to create a drop down menu that relates to another drop down menu
    By louise2613 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 08-18-2012, 01:49 PM
  4. Replies: 0
    Last Post: 06-25-2012, 03:22 PM
  5. Replies: 2
    Last Post: 01-08-2010, 09:11 AM
  6. Replies: 2
    Last Post: 01-30-2009, 04:23 PM
  7. Prevent delete on drop down menu
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2008, 06:29 AM
  8. [SOLVED] Drop down menu-How do you produce a drop down menu in a single cell in Excel
    By Freddo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-04-2006, 04:35 AM

Tags for this Thread

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