View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Printing certain pages

Hi Nick

One way

Sub Print_Worksheets()
Dim sh As Worksheet
Dim arr() As String
Dim N As Integer
N = 0
For Each sh In ThisWorkbook.Worksheets
If Left(sh.Name, 3) = "WIP" Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = sh.Name
End If
Next
With ThisWorkbook
.Worksheets(arr).PrintOut
.Worksheets(1).Select
End With
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Nick Shinkins" wrote in message ...
A rather simple problem but I can't find what I want in help.

I wish to loop through each sheet in the workbook and print those called WIP*

I was think of somethig like:

Private Sub PrintWIPButton_Click()

Dim SheetNum As Integer

For SheetNum = 1 To Worksheets.Count

If Sheets(SheetNum).Name Like "WIP*" Then

!!!! Add to a collection (or array?) of sheets !!!!

End If

Next SheetNum

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Worksheets(1).Select

End Sub

---------------------------------

I'm just having problems in defining a collection of sheets.

Can anyone fill in the missing line of code??

TIA!

Nick Shinkins