+ Reply to Thread
Results 1 to 5 of 5

Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

Hybrid View

kwoltman Print sheet 1 and sheet 2,... 04-04-2024, 11:41 AM
thomglea Re: Print sheet 1 and sheet... 04-04-2024, 12:02 PM
thomglea Re: Print sheet 1 and sheet... 04-04-2024, 12:02 PM
jolivanes Re: Print sheet 1 and sheet... 04-04-2024, 12:19 PM
kwoltman Re: Print sheet 1 and sheet... 04-04-2024, 01:11 PM
  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    78

    Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

    Hello all. Thanks for taking a look at this.

    I'm looking to create a Macro or VB Code and then assign the Marco to a button/image on Sheet 1.
    (Not sure if VB Code can be assigned to a button or not - sorry, I'm not real versed with this stuff)

    Sheet 1 will always print when the button is hit and the macro/VB code is executed
    Sheet 1 has a formula in Cell AS39 that pulls a value from Sheet 2
    If cell AS39 on Sheet 1 is > $0.00, then I need Sheet 2 to automatically print along with Sheet 1.
    If cell AS39 on Sheet 1 is = $0.00, then I need Sheet 2 to NOT print, so only Sheet 1 will print in this case.

    Cell AS39 will always be either $0.00 or some value > $0.00.

    I also need to know where to insert the code: Does it go into a Module? This workbook? Sheet1?
    If you can provide precise instructions for how and where to insert the code that would be greatly appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    11-29-2022
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    435

    Re: Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

    Sub PrintSheets()
    
        Sheets("Sheet 1").PrintOut
    
        If ThisWorkbook.Sheets("Sheet 1").Range("AS39") > 0 Then Sheets("Sheet 2").PrintOut
    
    End Sub

  3. #3
    Valued Forum Contributor
    Join Date
    11-29-2022
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    435

    Re: Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

    That code goes into a new Module

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,781

    Re: Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

    https://www.contextures.com/xlvba01.html
    https://www.ablebits.com/office-addi...a-macro-excel/
    https://wellsr.com/vba/2017/excel/ho...hape-in-excel/
    https://support.microsoft.com/en-au/...d-9c72c843a283


    Sub Maybe_So()
    Dim shArr
    If Sheets("Sheet1").Range("AS39").Value > 0 Then shArr = Array("Sheet1", "Sheet2") Else shArr = Array("Sheet1")
    ThisWorkbook.Sheets(shArr).PrintOut
    End Sub
    As a kid I used to watch the wizard of OZ and wondered how someone could talk if they didn't have a brain. Then I got social media.

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    78

    Re: Print sheet 1 and sheet 2, but sheet 2 only to print if cell value > 0

    This worked! Thank you.

+ 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. Replies: 1
    Last Post: 01-29-2022, 04:49 PM
  2. [SOLVED] Button To Print Specific cell Range On One Sheet In Print Selection
    By diddy47 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-03-2020, 06:23 AM
  3. [SOLVED] All data print in one sheet with Multiple Print Area seletion
    By rajeshn_in in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-10-2017, 11:49 AM
  4. VBA code to have print button and print the required area in sheet.
    By Ishwarind in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-09-2016, 03:54 AM
  5. Macro slows down when I print/print preview/page break a sheet
    By Grug in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2015, 08:59 PM
  6. If data is in cell copy to new sheet and print new sheet.
    By vitt4300 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2014, 08:53 PM
  7. Replies: 1
    Last Post: 11-24-2005, 07:29 AM

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