+ Reply to Thread
Results 1 to 2 of 2

VBA to Print Specific Worksheets base on if cell is > 0

  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    VBA to Print Specific Worksheets base on if cell is > 0

    hi all,
    im having difficulty with this macro. i'm attempting to have a clickable button that would print out certain spreadsheets based on certain criteria within a cell. Suppose cell A2 is greater than zero or is equivalent (referencing) a cell on a main sheet (should get the same result), i want to print out that spreadsheet and all others (there are over 50 sheets in this workbook) that fit that rule. here is what i have so far...

    Sub WSPrint()

    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Sheets
    If ws.Range("A2").Value = "> 0" Then
    ws.PrintOut
    End If
    Next ws

    End Sub

    OR

    Sub WSPrint()

    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Sheets
    If ws.Range("A2").Value = "Main!$A$3" Then
    ws.PrintOut
    End If
    Next ws

    End Sub
    Last edited by kboy1289; 10-25-2012 at 04:43 PM.

  2. #2
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: VBA to Print Specific Worksheets base on if cell is > 0

    solved. here is the solution i used, pretty simple actually

    Sub PrintWksht()

    Dim sht As Worksheet

    For Each sht In ThisWorkbook.Worksheets
    If sht.Range("A2").Value > 0 Then
    sht.PrintOut
    End If
    Next sht

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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