Hi everybody, hopefully somebody is able to solve my excel problem. I have a worksheet containing a lot of tabs (example file attached). Now I want excel to print out the tabs marked with an "x" in "main". Article and tab-name are always identical
Hi everybody, hopefully somebody is able to solve my excel problem. I have a worksheet containing a lot of tabs (example file attached). Now I want excel to print out the tabs marked with an "x" in "main". Article and tab-name are always identical
Last edited by telekomhater; 01-14-2011 at 05:52 AM.
Hello telekomhater,
Welcome to the Forum!
The macro below has been added to the attached workbook. A button has been added to the "Main" sheet to run the macro.
Print Selected Sheets Macro
Sub PrintSelectedSheets() Dim Cell As Range Dim Rng As Range Dim RngEnd As Range Dim Wks As Worksheet Set Wks = ActiveSheet Set Rng = Wks.Range("A2") Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp) Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, Wks.Range(Rng, RngEnd)) For Each Cell In Rng If Cell <> "" Then On Error Resume Next If LCase(Cell.Offset(0, 2)) = "x" Then Sheets(Cell.Text).PrintOut End If If Err <> 0 Then MsgBox "Sheet '" & Cell & "' Not Found.", vbCritical + vbOKOnly Err.Clear End If End If Next Cell End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Star below the post.3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Leith,
many thanks again for creating this macro. Would you be that kind and let me know what I have to change inside? I want the macro to look up the 10th column for "x" and it should start doing this in line 6. I tried a lot, but can't get it to work.
Hello tlelkomhater,
The macro has been changed to start looking for "x"'s in column 10 (J) starting at row 6.
Sub PrintSelectedSheets() Dim Cell As Range Dim Rng As Range Dim RngEnd As Range Dim Wks As Worksheet Set Wks = ActiveSheet Set Rng = Wks.Range("J6") Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp) Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, Wks.Range(Rng, RngEnd)) For Each Cell In Rng If Cell <> "" Then On Error Resume Next If LCase(Cell) = "x" Then Sheets(Cell.Text).PrintOut End If If Err <> 0 Then MsgBox "Sheet '" & Cell & "' Not Found.", vbCritical + vbOKOnly Err.Clear End If End If Next Cell End Sub
Hi Leith,
a big THANK YOU from Germany. Now it works as it should do.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks