This code might do the trick for you:

Const SUMMARY_SHEETNAME As String = "Summary"

Sub HideUnhideSelectedSheets()
    Dim rCell As Range
    For Each rCell In Range(Worksheets(SUMMARY_SHEETNAME).Range("A2"),
Worksheets(SUMMARY_SHEETNAME).Range("A" & Rows.Count).End(xlUp))
        Dim sh As Worksheet
        On Error Resume Next
        Set sh = Worksheets(rCell.Value)
        If Not sh Is Nothing Then
            If UCase(rCell.Offset(, 1).Value) = "YES" Then
                sh.Visible = xlSheetHidden
            Else
                sh.Visible = xlSheetVisible
            End If
        End If
        Set sh = Nothing
    Next rCell
End Sub

Sub PrintSelectedSheets()
    Dim rCell As Range
    For Each rCell In Range(Worksheets(SUMMARY_SHEETNAME).Range("A2"),
Worksheets(SUMMARY_SHEETNAME).Range("A" & Rows.Count).End(xlUp))
        Dim sh As Worksheet
        On Error Resume Next
        Set sh = Worksheets(rCell.Value)
        If Not sh Is Nothing Then
            If UCase(rCell.Offset(, 2).Value) = "YES" Then
                sh.PrintOut
            End If
        End If
        Set sh = Nothing
    Next rCell
End Sub

Rolf Jaeger
SoarentComputing
http://soarentcomputing.com/SoarentComputing/ExcelSolutions.htm


On Nov 26, 4:33 am, Manish Pansari <pansari.man...@gmail.com> wrote:
> Dear All,
>
> I want to create a macro by which I want to print relevant sheet and
> want to hide/unhide irrelevant sheets. I want to list out all working
> sheet in one sheet and in column next to the name of the worksheet i
> want to put Yes/No for hide the sheet. Once i decide the whole sheet
> which i want to hide i want to run the macro. e.g.
>
> Column A              Column B            Column C
>                                 Hide                    Print
> Sheet1                     Yes                        No
> Sheet2                      NO                        Yes
> Sheet3                     No                          Yes
> Sheet4                     Yes                        Yes
>
> How I can do this, pls help me. I want to assign separate macro
> commend for hide/Unhide and print sheet.
>
> Thnxs in advance.
>
> -
> Manish

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

Reply via email to