View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Can I copy just the visible sheets?

Trefor

No error trapping and Book4.xls must be open.


Private Sub Visble_Only()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
If ws.Visible = True Then
ws.Copy Befo=Workbooks("Book4.xls").Sheets(1)
End If
Next
End Sub


Gord Dibben MS Excel MVP


On Sat, 2 Sep 2006 10:43:01 -0700, Trefor wrote:

I realise I can make the sheets I want to copy visible, then copy them as per
below (using variables for sheet names)

Sheets(Array(CCRFsheet2, CCRFsheet3, CCRFsheet4a, CCRFsheet6,
CCRFsheet7a, CCRFsheet7b, CCRFsheet8, CCRFsheet9)).Copy

But is it possible to write a macro that will work out what sheets are
visible and then only copy those sheets to another WorkBook?