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