+ Reply to Thread
Results 1 to 14 of 14

Print Certain Worksheets Based On Cell Value In Each

  1. #1
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Print Certain Worksheets Based On Cell Value In Each

    I started a similar thread recently but I've had to change up my workbook so I'm now having an issue getting my print function to work correctly.

    My workbook has 150 tabs or sheets. I want to assign a macro to print all sheets in the workbook that have a certain value in a particular cell of each sheet.

    In cell $AD$4 of each sheet, it will have "Print" or "NoPrint"
    If it has "Print", I want the sheet to print.
    If it has "NoPrint" I do not want the sheet to print.

    Here is the code that I'm trying to use but I'm getting a debug error.

    Can anyone offer a solution?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Thanks for assisting! I'm getting the following error using that code.

    Attachment 650691

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    Welcome to the forum

    Please attach a sample workbook...
    Sorry... I've removed 145 tabs and made a small test version with only a handful of tabs instead. I've attached it here for you. In this example, only two sheets should print. Employee1 and Employee2
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Mehmetcik - I'm not sure how you and the others on this website, that help people like myself, know how to write code like this. It's truly amazing for a novice like myself. Thank you so much for the assistance!

  8. #8
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Mehmetcik - Sorry but I had to open this back up. The macro is not behaving properly. If looking at my example that I attached for you already, I inputted 3 employee names. It will print 1, 2 & 3, then print 3 again, skip 2 and print 1 again. If I enter an employee1 and an employee 3, it will print 1, then 3, 3 again and 1 again last.

  9. #9
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    I have tried with 4 and 5 users inputted and the results are much the same. It goes through the sheets and when it gets to the last one, it cycles back to the beginning, giving me two copies of every sheet that prints.
    Last edited by Gtrtim112; 11-21-2019 at 01:06 PM.

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    Very strange behavior

    Let me annotate the macro to see what is happening.

    Ok I cannot see anything wrong with the Macro.
    Perhaps you have set a page to print twice. The macro should overwrite that. But excel does funny things at times.


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-23-2019 at 07:39 PM.

  11. #11
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    Very strange behavior

    Let me annotate the macro to see what is happening.

    Ok I cannot see anything wrong with the Macro.
    Perhaps you have set a page to print twice. The macro should overwrite that. But excel does funny things at times....
    I definitely don't have any to print twice. I made the first sheet and copied it over and over. The print area was set from the start to 1 page wide and x 1 page tall. I opened the file in my Citrix environment versus my local environment (laptop) and got the same result.

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    I a sorry I cannot help.

    Do you know how to step through the program to see what it is doing?

    Also

    Do you have any print macros open. Sometimes you will find that excel leaps from the macro you are running to another macro.

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Print Certain Worksheets Based On Cell Value In Each

    The Macro works correctly.


    Is is printing Employees 1 to 6.

    You must have messed up the Employee list.

    I have written a goto sheet macro to help you navigate around the workbook.

    Press Ctrl z on any sheet and you will be taken to the Employee list.

    Press Ctrl z on column C of the Employee List to go to that Employee sheet.

    Please Login or Register  to view this content.



    Please Login or Register  to view this content.

  14. #14
    Forum Contributor Gtrtim112's Avatar
    Join Date
    04-12-2013
    Location
    Alabama, USA
    MS-Off Ver
    Excel 2016
    Posts
    332

    Re: Print Certain Worksheets Based On Cell Value In Each

    Quote Originally Posted by mehmetcik View Post
    The Macro works correctly....
    I tried it again and it it is working now. Not sure why or what the difference is. I went back to the original file. Very strange.

    Anyways... thank you so much for the help and being patient with me. Sorry for the troubles. I appreciate the assistance, though!
    Last edited by Gtrtim112; 11-22-2019 at 04:51 PM.

+ 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. [SOLVED] Macro To Print Worksheets Based On Cell Value
    By Gtrtim112 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-17-2019, 09:25 AM
  2. Set Order Worksheets Print Based on Cell Value
    By dumbtree in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2019, 03:49 PM
  3. VBA - Print Worksheets Based on Cell Value
    By Hazelnut in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2018, 06:48 PM
  4. Create and print report from across multiple worksheets based on cell values
    By stkachuk07 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2016, 02:57 PM
  5. Macro to Print worksheets based on Criteria.
    By Jvollmer33 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2013, 08:30 AM
  6. VBA - Print Worksheets Based on Cell Value
    By thesonofdarwin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-19-2012, 02:59 PM
  7. Need to print 7 worksheets based cell on another sheet
    By GSXR1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2007, 03: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