Closed Thread
Results 1 to 4 of 4

Worksheets code

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    So Cal
    MS-Off Ver
    Excel 2003
    Posts
    10

    Unhappy Worksheets code

    Hi All,
    I have a wb with 3 worksheets. Only one sheet requires that one cell be filled in order to print. If the cell is not filled in, I get my message box below. My problem is that I get that message on all sheets in the workbook even if I am not working in that particular worksheet.
    Any ideas? I only want the message to appear in that one worksheet.



    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If Worksheets("Time Comps").Range("H12") = "" Then
    MsgBox "You must enter the Violation Date"
    Cancel = True
    End If
    End Sub

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Worksheets code

    So, if the cell is empty, but you are on a different worksheet, you want it to print anyway? It should only not print if the cell is empty AND the active sheet is "Time Comps"? If so, the solution that comes to mind is to:

    Please Login or Register  to view this content.
    Pauley

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

    Re: Worksheets code

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

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

    Free DataBaseForm example

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Worksheets code

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

Closed 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