View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Copy Multiple Sheets, Except Q

Add and IF statement at the bottom like below.

First = True
For Each sht In ThisWorkbook.Sheets
Select Case sht.Name


Case "Header", "A", "B", "C", "D"
'Do Nothing
Case Else
If First = True Then
'Create New workbook
sht.Copy
Set Destwb = ActiveWorkbook
First = False
Else
With Destwb
sht.Copy after:=.Sheets(.Sheets.Count)
End With
End If
End Select
Next sht

If First = True then
msgbox("No sheets found to copy")
End IF

"Seanie" wrote:

Great, I got it to work as below. Finally how could I place a Msg Box
pop up, if there are no sheets to copy, i.e. the only sheets that are
in the source workbook are A,B,C,D?


First = True
For Each sht In ThisWorkbook.Sheets
Select Case sht.Name


Case "Header", "A", "B", "C", "D"
'Do Nothing
Case Else
If First = True Then
'Create New workbook
sht.Copy
Set Destwb = ActiveWorkbook
First = False
Else
With Destwb
sht.Copy after:=.Sheets(.Sheets.Count)
End With
End If
End Select
Next sht