Results 1 to 9 of 9

Code runs on entire workbook...need it to only run on one worksheet

Threaded View

jrobertson2403 Code runs on entire... 11-25-2013, 01:00 PM
Solus Rankin Re: Code runs on entire... 11-25-2013, 01:08 PM
jrobertson2403 Re: Code runs on entire... 11-25-2013, 01:33 PM
JOHN H. DAVIS Re: Code runs on entire... 11-25-2013, 01:10 PM
MarvinP Re: Code runs on entire... 11-25-2013, 01:12 PM
alansidman Re: Code runs on entire... 11-25-2013, 01:21 PM
jrobertson2403 Re: Code runs on entire... 11-25-2013, 01:25 PM
6StringJazzer Re: Code runs on entire... 11-26-2013, 10:09 AM
jrobertson2403 Re: Code runs on entire... 11-28-2013, 04:50 PM
  1. #1
    Registered User
    Join Date
    11-02-2013
    Location
    Philadelphia,PA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question Code runs on entire workbook...need it to only run on one worksheet

    Hey there,

    I am new to writing vba code and came across this problem. Seems pretty simple but I can't seem to get it to work. I am looking for the below code to work only on sheet1 of the workbook. Please help??

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    
      If Range("B3") = 0 Then
    Cancel = True
        Msgbox "Please fill out Date", vbInformation, "DSR_Autochecker"
    
    ElseIf Range("S3") = 0 Then
    Cancel = True
        Msgbox "Please fill out Store #", vbInformation, "DSR_Autochecker"
        
        ElseIf Range("K22") = 0 Then
        Cancel = True
        Msgbox "Please fill out Deposit Bag Number", vbInformation, "DSR_Autochecker"
        
        ElseIf Range("R40") = 0 Then
        Cancel = True
        Msgbox "Please fill out Preparer Name", vbInformation, "DSR_Autochecker"
        
        ElseIf Range("R41") = 0 Then
        Cancel = True
        Msgbox "Please fill out Witness Name", vbInformation, "DSR_Autochecker"
        
    
        
    End If
    
    End Sub
    Last edited by alansidman; 11-25-2013 at 01:21 PM. Reason: code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Shortening Code so it runs if another workbook is acitve
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-17-2012, 06:47 AM
  2. Combobox code runs while closing and opening of workbook
    By shreyasdate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-07-2012, 07:47 AM
  3. worksheet combo box code runs when workbook open and close
    By hilander in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-29-2008, 10:25 PM
  4. Code runs in wrong workbook?
    By Ian in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-27-2005, 11:00 AM
  5. When code runs...worksheet acts a little strange
    By KimberlyC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2005, 12:06 PM

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