+ Reply to Thread
Results 1 to 12 of 12

VBA to print based on cell value

  1. #1
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37

    VBA to print based on cell value

    Hi

    I want to print X copies of worksheet 1 based on a qty in a cell C3

    Then to Print X copies of worksheet 2 based on cell C4

    But if cell C3 is blank i still want to print worksheet 2

    but when i run the macro i get a error because there is no value in C3

    Can anyone advise me on how to get the macro to continue if C3 is blank?

    Thank you any help / advice you can give

    Please note macro im using on Sheet 3 of the attachment
    Attached Files Attached Files
    Last edited by Morleyb; 04-09-2020 at 05:46 AM. Reason: Attachment added

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: VBA to print based on cell value

    Can you supply the code you need help with?

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,162

    Re: VBA to print based on cell value

    I am assuming the qty's for both sheet printouts are on sheet1 C3 & C4

    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37

    Re: VBA to print based on cell value

    attachment added - Macro on sheet 3

  5. #5
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37

    Re: VBA to print based on cell value

    i tried to keep things simple in my orignal post thinking i could just extract some of the code to add to mine,
    this is not the case. i have added my attachment and the included the macro on sheet 3.

    This macro works has log has there are qtys in the coloum C

    Please help

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,162

    Re: VBA to print based on cell value

    Code in post3 works...

  7. #7
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37

    Re: VBA to print based on cell value

    Quote Originally Posted by sintek View Post
    Code in post3 works...
    can you please give more detail and how to combine youre code with mine?


    Capture.PNG
    Last edited by Morleyb; 04-09-2020 at 07:28 AM.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,162

    Re: VBA to print based on cell value

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37

    Re: VBA to print based on cell value

    Quote Originally Posted by sintek View Post
    Please Login or Register  to view this content.
    If you run my code you will see that it prints a selection of cells from sheet 2 and prints X copies based on the value in C3

    Then it selects and prints another section from sheet 2 and prints x copies based on cell C4

    If you then blank out C3 and re run the code you will see you get an error telling you that C3 must have a value more than 1.

    Sorry for messing you about but i am very greatful for the help

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,162

    Re: VBA to print based on cell value

    So...you don't want to print out x copies of sheet1 and sheet2..
    Your initial requirement in post 1 is misleading...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-09-2020 at 08:47 AM.

  11. #11
    Registered User
    Join Date
    06-15-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    37
    Quote Originally Posted by sintek View Post
    So...you don't want to print out x copies of sheet1 and sheet2..
    Your initial requirement in post 1 is misleading...
    Please Login or Register  to view this content.
    Thank you so much. Workds a treat

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,162

    Re: VBA to print based on cell value

    Pleasure...in future...No need to quote entire posts...It just clutters the thread...
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Print Certain Worksheets Based On Cell Value In Each
    By Gtrtim112 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-22-2019, 04:44 PM
  2. Print first 5 pdf files based on cell value
    By F1ash in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-22-2018, 01:00 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. Print pdf file by based on cell value
    By serious123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2015, 08:02 AM
  5. 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
  6. print a report based on cell value
    By excelluni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2009, 07:57 AM
  7. Sort and print based on Cell Value
    By jamesstorx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-21-2009, 07:58 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