Olá pessoal, boa tarde!
Estou tentando montar uma macro que copie a planilha que estou em um novo arquivo mas colando somente valores.
Hoje utilizo o código abaixo que cria uma sheet no meu arquivo de apoio copiando e colando apenas os valores.
-CODIGO QUE UTILIZO:
Sub CopiaSomenteConteudo()
Dim NewSheet As Worksheet, CurrentSheet As Worksheet
Set CurrentSheet = ActiveSheet
Set NewSheet = ThisWorkbook.Worksheets.Add
NewSheet.Name = "Resultado"
CurrentSheet.Cells.Copy
NewSheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Set NewSheet = Nothing
Set CurrenSheet = Nothing
End Sub
Porém, a questão é que preciso que essas informações sejam copiadas e coladas para um novo arquivo de forma automática pela mesma macro e não criando uma sheet no mesmo arquivo.
-CODIGO QUE ESTOU TENTANDO:
Sub CriaArquivo()
Dim NovoArquivoXLS As Workbook
Dim sht As Worksheet
CurrentSheet.Cells.Copy
Set NovoArquivoXLS = Application.Workbooks.Add
NewSheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Set NewSheet = Nothing
Set CurrenSheet = Nothing
NovoArquivoXLS.SaveAs mPathSave & "I1" & mPlan.Name & ".xls"
MsgBox "Novo arquivo salvo em: " & mPathSave & "I1" & mPlan.Name & ".xls", vbInformation
End Sub
Sou iniciante e não estou conseguindo criar a macro... podem me ajudar dizendo onde estou errando?
Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Copiar e colar somente dados criando um novo arquivo
Re: Copiar e colar somente dados criando um novo arquivo
Boa tarde Thais.
Tente o seguinte código:
At.te Nathan. Caso sua duvida tenha sido resolvida favor acrescentar [RESOLVIDO] ao título do tópico.
Tente o seguinte código:
Código: Selecionar todos
Sub CopiaPlanilha()
Dim NewSheet As Worksheet, CurrentSheet As Worksheet
Set CurrentSheet = ActiveSheet
Set NewSheet = ThisWorkbook.Worksheets.Add
NewSheet.Name = "Resultado"
CurrentSheet.Cells.Copy
NewSheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
NewSheet.Copy
ActiveWorkbook.SaveAs FileName:=NomeDoArquivo, FileFormat:=FormatoDoArquivo
Set NewSheet = Nothing
Set CurrenSheet = Nothing
End Sub