VBA EXCEL - COPIAR DETERMINADAS FOLHAS DE CÁLCULO PARA UM NOVO LIVRO (Copy some specific worksheets to a new workbook)

Criar um novo ficheiro, a partir do livro existente, exportando ou copiando apenas as folhas de cálculo que desejamos.
Create a new file from the existing book, exporting or copying only the worksheets that we desire.

Sub ExportarFolhas()
Dim wb As Workbook
Dim fNome As Variant
Worksheets(array("Folha1", "Folha2")).Copy  '
cria novo livro (Creates new workbook)
Set wb = ActiveWorkbook
fNome = Application.GetSaveAsFilename( _
 FileFilter:
="Excel Files (*.xla), *.xla", _
 Title:="Especificar Localização:") 'Specify Location for Copy
If fNome = False Then
 '  Se o utilizador escolhe "cancelar" a cópia é eliminada
 ' If user has chosen "cancel" delete the copy
 wb.Close Savechanges:=False
Else

 wb.SaveAs Filename:=fNome
 wb.Close Savechanges:=False
End If
End Sub

Comentários

Mensagens populares deste blogue

EXCEL 2007 - FUNÇÕES PARA CALCULAR HORAS (Functions to Calculate Hours)

CONVERTER HORAS EM DIAS DE TRABALHO (Convert Hours to Workdays)

VBA EXCEL - OCULTAR LINHAS EM BRANCO (Hide Blank Rows)