+ Reply to Thread
Results 1 to 17 of 17

Click here to print sheet

  1. #1
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Click here to print sheet

    Hello everybody. I created a spreadsheet that has dropdowns and cells for people to fill in information. My supervisor has now asked me to set it up so that the form won't print unless all necessary information is filled in. I figured the easiest way to do this is create a button for printing the form.

    I selected the cells I want as the "button". Now here is problem, I would like the button to be greyed out until all the necessary cells are filled. How can I have the "button" able to be pressed, but only be active if all the cells contain information?

    Any help on this would be greatly appreacited. Thank you in advance.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Click here to print sheet

    Hi, pboost1,

    if the cells are empty/blank you could use WorksheetFunction.CountBlank to get the number of empty cells. If the user enters manually or by using DropDown the Worksheet_Change-event could be used to monitor the button.

    If the cells show a standard text instead of the necessary action you could build a range to check and loop through all cells of the range and compare the value of the cell to the standard text and add 1 to a variable. If the variable is equal to the number of cells in the range the button could be activated.

    Another way would be to get this as the starting part of the button and exit the sub if the information has not been entered (show a message to the user) while continuing if the necessary information has been entered.

    HTH,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-14-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Click here to print sheet

    in cell X10000 or what ever, add in a formula =IF(OR(A1="",D2="",G5=""),0,1). Change A1, D2, G5 to every cell that you need populated. Then add this to the VBA for that sheet, not "ThisWorkbook".


    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Quote Originally Posted by HaHoBe View Post
    Hi, pboost1,

    if the cells are empty/blank you could use WorksheetFunction.CountBlank to get the number of empty cells. If the user enters manually or by using DropDown the Worksheet_Change-event could be used to monitor the button.

    If the cells show a standard text instead of the necessary action you could build a range to check and loop through all cells of the range and compare the value of the cell to the standard text and add 1 to a variable. If the variable is equal to the number of cells in the range the button could be activated.

    Another way would be to get this as the starting part of the button and exit the sub if the information has not been entered (show a message to the user) while continuing if the necessary information has been entered.

    HTH,
    Holger
    I am trying to figure out what to do with your suggestion. Is there any way of possibly providing a sample. Thanks for the help you have provided.
    Last edited by pboost1; 02-13-2014 at 05:30 PM.

  5. #5
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Quote Originally Posted by jwlamb View Post
    in cell X10000 or what ever, add in a formula =IF(OR(A1="",D2="",G5=""),0,1). Change A1, D2, G5 to every cell that you need populated. Then add this to the VBA for that sheet, not "ThisWorkbook".


    Please Login or Register  to view this content.
    Hello, I copied your code, and adjusted it to where I need. I also have the button setup with a macro to print. I must have something wrong as the button prints regardless of what that value is.

    Just to ask, am I suspose to have a macro for printing set in the button? Thanks for the help.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Click here to print sheet

    Hi, pboost1,

    maybe consider not to fully quote the posts you are answering to according to the forum rules.

    Is there any way of possibly providing a sample.
    The code here entereed into ThisWorkbook checks the cells A1, B2 and C3 and will allow printing only when they are filled:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Hello HaHoHe, I copied your code to my workbook and it is still allowing me to print. I downloaded your spreadsheet and am not seeing a difference in what you wrote and what I copied. Am I doing something wrong? I will try to make a sample worksheet and upload it. Thanks again for the help.

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

    Re: Click here to print sheet

    Could try putting this code in the worksheet part of the macros. Go to VBA, double click the sheet you want to monitor, and paste this code. Change the contents of the "set range" to match your cells, and the button name as well.... This will hide the button for you.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Here is a sample similiar to what I have at work
    Attached Files Attached Files
    Last edited by pboost1; 02-14-2014 at 03:40 PM. Reason: uploaded wrong sample

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

    Re: Click here to print sheet

    Assuming the Item fields need to be populated, the attached sheet might do what you want, it hides the print sheet button until all 5 items are filled.

    EDIT: Just updated file with a method that will disable and enable without hiding...
    Attached Files Attached Files
    Last edited by Arkadi; 02-14-2014 at 04:22 PM.

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Click here to print sheet

    Hi, pboost1,

    attaching a macro-free workbook may be showing that you didnīt insert a workbook level event into the workbook where it should be used.

    Ciao,
    Holger

  12. #12
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Thanks for everybodys help on this. With all that has been submitted, I belive I was able to get what I needed. I can only work on the work spreadsheet as work so I have limited time to play with the spreadsheet. I will leave this open for a couple of more days and if things work the way I want it to, then I will close it out. Thanks again;

  13. #13
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    I am uploading a sample of what I was able to come up with. I cannot seem to get the visual basic to state the name of the information being requested instead of the cell number. Also, A slight change was made and now when a reason is needed on two cells, we need the drop down filled out and the reason (if aplpicable). Is it possible to have it state the name and not allow printing unless the reason is filled out as well.
    Attached Files Attached Files

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Click here to print sheet

    Hi, pboost1,

    Also, A slight change was made and now when a reason is needed on two cells, we need the drop down filled out and the reason (if aplpicable)
    How will you do so with merged cells?

    Please Login or Register  to view this content.
    Ciao,
    Holger

  15. #15
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    Thanks HaHoHe. what you have provided works great. The title show up for what is needed instead of the cell reference. Thanks a lot.
    Last edited by pboost1; 04-12-2014 at 01:20 PM.

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Click here to print sheet

    Hi, pboost1,

    as you have merged the columns what about an entry on different rows (at least that was what I understood from your post)? Does the code perform like you want?

    Ciao,
    Holger

  17. #17
    Forum Contributor
    Join Date
    07-16-2004
    Location
    Illinois
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Click here to print sheet

    my boss would have liked that, but they were more concerned about having what needs to be filled out if anything is missing. Thanks again.

+ 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. Click on Print Button webform
    By itselflearn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2013, 10:08 PM
  2. Print Word Doc on Click
    By tristangemus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-18-2013, 07:45 AM
  3. [SOLVED] Click Print on Userform and Print a file
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2011, 07:57 AM
  4. Click and Print Macro
    By banyard2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2011, 09:49 AM
  5. click button and print sheet
    By Sonyk in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-29-2009, 01:03 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