+ Reply to Thread
Results 1 to 6 of 6

disable printing due to empty cells

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-18-2013
    Location
    utah
    MS-Off Ver
    2010
    Posts
    668

    disable printing due to empty cells

    is there vba to disable printing if all cells within a range and empty?

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: disable printing due to empty cells

    In the VBA editor, double-click "This Workbook" and past this code there. In this code the range of cells that can't be empty is A5 to A10, but you can change that as needed. Also, the code assumes Sheet1 is the sheet with the cells that can't be empty, so change that as needed too.

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    
    Dim myrange As Range
    Dim mycell As Range
    
    Cancel = True
    Set myrange = Worksheets("Sheet1").Range("A5:A10")
    For Each mycell In myrange
        If mycell.Value <> "" Then Cancel = False
    Next mycell
    
    End Sub
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Contributor
    Join Date
    04-18-2013
    Location
    utah
    MS-Off Ver
    2010
    Posts
    668

    Re: disable printing due to empty cells

    with this do all cell in the range have to have data? I need it to work if only 1 has data but not run if no cells in the range have data?

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: disable printing due to empty cells

    This code would not print if ALL cells in the range are blank. If even just one cell in the range has data, then it will print.

  5. #5
    Forum Contributor
    Join Date
    04-18-2013
    Location
    utah
    MS-Off Ver
    2010
    Posts
    668

    Re: disable printing due to empty cells

    how would i add a msg box to let someone know can't print until info is entered.

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: disable printing due to empty cells

    Use this ammended code, just change the part in the quotes (the msgbox line) to say what you want:

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    
    Dim myrange As Range
    Dim mycell As Range
    
    Cancel = True
    Set myrange = Worksheets("Sheet1").Range("A5:A10")
    For Each mycell In myrange
        If mycell.Value <> "" Then Cancel = False
    Next mycell
    If Cancel = True Then MsgBox ("Can't print until all cells are filled")
    End Sub

+ 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. disable printing if specific cells are empty - multiple sheets-
    By zanael in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2014, 08:37 PM
  2. Excel 2007 : Printing Empty cells
    By ianxj in forum Excel General
    Replies: 3
    Last Post: 03-20-2011, 10:34 PM
  3. Avoid printing empty cells
    By Max30 in forum Excel General
    Replies: 2
    Last Post: 02-08-2010, 06:30 PM
  4. How do I keep From printing Blank/Empty cells.
    By Energymiser in forum Excel General
    Replies: 6
    Last Post: 10-30-2008, 09:23 AM
  5. Disable printing a spreadsheet until assinged cells have data
    By gebfixit in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-02-2006, 04:50 PM

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