Notifications
Clear all

Macro para salvar

2 Posts
2 Usuários
0 Reactions
715 Visualizações
(@dudureuw)
Posts: 3
New Member
Topic starter
 

Pessoal,

estou com problema na execução de uma macro. E a pessoa que a criou não trabalha mais aqui e eu não entendo nada de VB

o erro está acontecendo já na primeira linha "format"

Public Sub GeraPlanilha()
'
'

dia_leitura = Format(Plan4.Cells(2, 13), "dd/mm/yy")
dia_leitura = Plan4.Cells(2, 13)
ano = Year(dia_leitura)
Mes = Format(Month(dia_leitura), "00")
Dia = Format(Day(dia_leitura), "00")
Mes2 = Format(dia_leitura, "mmmm")

Diretorio_Branco = "\bcp08OrgCorporativoCoprod2 OPERADOR DE PRODUÇÃO3 P1Boletim da sala de controle" ' caminho dos arquivos diários"
Diretorio_Planilhas = "\bcp08OrgCorporativoCoprod2 OPERADOR DE PRODUÇÃO3 P1Boletim da sala de controle" & Mes & " - " & Mes2 ' caminho dos arquivos diários"
Arquivo_Branco = Diretorio_Branco & "BSC_em_branco.xls" ' nome do arquivo em branco
Arquivo_Final = Diretorio_Planilhas & "BSC " & Dia & -Mes & -ano & ".xls" ' nome arquivo final

'
Workbooks.Open Filename:=Arquivo_Branco

Windows("BSC P-08.xls").Activate
Range("C7:P31").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("C7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("M2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("O2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("C32:L32").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("C32").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("O32").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("O32").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("C35:C36").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("C35").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("C38:C39").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("C38").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("C41:E41").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("C41").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("G41:I41").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("G41").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("K41:M41").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("K41").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Windows("BSC P-08.xls").Activate
Range("E35").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("E35").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("E38").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("E38").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("G34:G39").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("G34").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("J34:J39").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("J34").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("L37").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("L37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("L39").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("L39").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("N35").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("N35").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("N37").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("N37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("N38").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("N38").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("L35").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("L35").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("BSC P-08.xls").Activate
Range("E43:G46").Select
Application.CutCopyMode = False
Selection.Copy
Windows("BSC_em_branco.xls").Activate
Range("E43").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

ActiveWorkbook.SaveAs Filename:= _
Arquivo_Final, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWindow.Close

End Sub

 
Postado : 29/08/2015 5:32 am
(@mprudencio)
Posts: 2749
Famed Member
 

E mais facil vc explicar o que a macro deveria fazer e disponibilizar o arquivo como modelo nao precisa ter dados reais basta ter dados de exemplo.

Marcelo Prudencio
Microsoft Excel Brasil no Facebook

"Começar já é a metade do caminho."
Autor Desconhecido

Simplifica que simples fica.
Nicole Tomazella.

"O Simples é Sempre Melhor Que o Complicado"
Jorge Paulo Lemann.

 
Postado : 29/08/2015 10:42 am