+ Reply to Thread
Results 1 to 5 of 5

Required Field

  1. #1
    Registered User
    Join Date
    07-26-2005
    Posts
    11

    Question Required Field

    I am trying to create a spread sheet that would require a person to fill in certain fields before they could print a worksheet. Is this possible?

  2. #2
    Chip Pearson
    Guest

    Re: Required Field

    Put the following code in the ThisWorkbook module

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If Worksheets("Sheet1").Range("A1") = "" Then '<<< change as
    required
    Cancel = True
    End If
    End Sub

    Change the worksheet name and cell reference to the appropriate
    values.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "tiab86" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I am trying to create a spread sheet that would require a
    > person to fill
    > in certain fields before they could print a worksheet. Is this
    > possible?
    >
    >
    > --
    > tiab86
    > ------------------------------------------------------------------------
    > tiab86's Profile:
    > http://www.excelforum.com/member.php...o&userid=25628
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=530950
    >




  3. #3
    Tom Ogilvy
    Guest

    RE: Required Field

    Use the beforeprint event to check
    If they are not filled in, then display a msgbox and set the cancel variable
    to True.

    http://www.cpearson.com/excel/events.htm

    for an overview of events.

    --
    Regards,
    Tom Ogilvy


    "tiab86" wrote:

    >
    > I am trying to create a spread sheet that would require a person to fill
    > in certain fields before they could print a worksheet. Is this possible?
    >
    >
    > --
    > tiab86
    > ------------------------------------------------------------------------
    > tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
    > View this thread: http://www.excelforum.com/showthread...hreadid=530950
    >
    >


  4. #4
    Registered User
    Join Date
    07-26-2005
    Posts
    11

    Angry

    Ok,
    I'm a bit confused.
    When I put the values in below it appears to do nothing.
    I'm new to VB so that's probably part of my problem.
    What am I doing wrong?
    I get the following error:


    Run-time error '438':
    Object doesn't support this property or method


    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If Worksheets("Packing Slip").Range("U10") = "" Then '
    Cancel = True
    Print
    End If
    End Sub

  5. #5
    Tom Ogilvy
    Guest

    Re: Required Field

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If Worksheets("Packing Slip").Range("U10") = "" Then '
    Cancel = True
    End If
    End Sub

    You have already hit the print button, so you don't need to do anything for
    it to print. What you are doing is cancelling that print if U10 of Packing
    Slip is blank.

    Immediately after Cancel=True you might want to put in

    Msgbox "Printing cancelled until you put a value in U10"



    --
    Regards,
    Tom Ogilvy



    "tiab86" wrote:

    >
    > Ok,
    > I'm a bit confused.
    > When I put the values in below it appears to do nothing.
    > I'm new to VB so that's probably part of my problem.
    > What am I doing wrong?
    > I get the following error:
    >
    >
    > Run-time error '438':
    > Object doesn't support this property or method
    >
    >
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > If Worksheets("Packing Slip").Range("U10") = "" Then '
    > Cancel = True
    > Print
    > End If
    > End Sub
    >
    >
    > --
    > tiab86
    > ------------------------------------------------------------------------
    > tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
    > View this thread: http://www.excelforum.com/showthread...hreadid=530950
    >
    >


+ 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