Notifications
Clear all

Erro na linha de comando do vba

2 Posts
2 Usuários
0 Reactions
1,039 Visualizações
(@rpedrao)
Posts: 1
New Member
Topic starter
 

Boa tarde Amigos.

Estou com um erro aqui no meu codigo e não consigo resolve-lo... ele tarja em amarelo uma linha aqui e não sei o que fazer pra consertar e fazer funfar o codigo.

Sub Atualizar()
'
' Macro para atualizar banco de dados
'
'
' Desligar cálculo automático
'
Application.ScreenUpdating = False
Application.Calculation = xlManual
'
'
'
' *** Pasta Controle Processos - Atualiza dados das pastas dos compradores ***
'
'
' Eliminar filtro
'
Sheets("Controle Processos").Select
Rows("4:4").Select
Selection.AutoFilter
'
'
' Selecionar banco de dados e apagar
'
Range("B5:AE50000").Select
Selection.ClearContents
'
'
' Copiar banco de dados - Requerimentos Pendentes-Fabia.xlsx
'
Workbooks.Open Filename:= _
"Z:_SERVIÇOSCompradores_Planilhas Req PendRequerimentos Pendentes-Fabia.xlsx"
Sheets("Controle Processos").Select
Rows("2:2").Select
Selection.AutoFilter
'
' Eliminar linhas em branco
'
Range("A2:AD5000").Select
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Controle Processos").Sort
.SetRange Range("A2:AD5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
' Copiar dados
'
Range("A1").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Check").Select
Range("D6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
Windows("Requerimentos Pendentes-Fabia.xlsx").Activate
Sheets("Controle Processos").Select
Range("A3:AD50000").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Controle Processos").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Requerimentos Pendentes-Fabia.xlsx").Activate
Application.DisplayAlerts = False
ActiveWindow.Close
'
'
' Copiar bando de dados - Requerimentos Pendentes-Fabiola.xlsx
'
Workbooks.Open Filename:= _
"Z:_SERVIÇOSCompradores_Planilhas Req PendRequerimentos Pendentes-Fabiola.xlsx"
Sheets("Controle Processos").Select
Rows("2:2").Select
Selection.AutoFilter
'
' Eliminar linhas em branco
'
Range("A2:AD5000").Select
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Controle Processos").Sort
.SetRange Range("A2:AD5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
' Copiar dados
'
Range("A1").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Check").Select
Range("D7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
Windows("Requerimentos Pendentes-Fabiola.xlsx").Activate
Sheets("Controle Processos").Select
Range("A3:AD50000").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Controle Processos").Select
Range("B5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Requerimentos Pendentes-Fabiola.xlsx").Activate
ActiveWindow.Close

' Copiar banco de dados - Requerimentos Pendentes-Giovanni.xlsx
'
Workbooks.Open Filename:= _
"Z:_SERVIÇOSCompradores_Planilhas Req PendRequerimentos Pendentes-Giovanni.xlsx"
Sheets("Controle Processos").Select
Rows("2:2").Select
Selection.AutoFilter
'
' Eliminar linhas em branco
'
Range("A2:AD5000").Select
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Controle Processos").Sort
.SetRange Range("A2:AD5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
' Copiar dados
'
Range("A1").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Check").Select
Range("D8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
Windows("Requerimentos Pendentes-Giovanni.xlsx").Activate
Sheets("Controle Processos").Select
Range("A3:AD50000").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Controle Processos").Select
Range("B5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Requerimentos Pendentes-Giovanni.xlsx").Activate
ActiveWindow.Close
'
'
' Copiar bando de dados - Requerimentos Pendentes-Yara.xlsx
'
Workbooks.Open Filename:= _
"Z:_SERVIÇOSCompradores_Planilhas Req PendRequerimentos Pendentes-Yara.xlsx"
Sheets("Controle Processos").Select
Rows("2:2").Select
Selection.AutoFilter

'
' Eliminar linhas em branco
'
Range("A2:AD5000").Select
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Controle Processos").Sort
.SetRange Range("A2:AD5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
' Copiar dados
'
Range("A1").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Check").Select
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
Windows("Requerimentos Pendentes-Yara.xlsx").Activate
Sheets("Controle Processos").Select
Range("A3:AD50000").Select
Selection.Copy
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Controle Processos").Select
Range("B5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Requerimentos Pendentes-Yara.xlsx").Activate
ActiveWindow.Close
'
'
' Copiar banco de dados - Requerimentos Pendentes-Erik.xlsx
'
' Workbooks.Open Filename:= _
' "Z:_MICompradores_Planilhas Req PendRequerimentos Pendentes-Erik.xlsx"
' Sheets("Controle Processos").Select
' Rows("2:2").Select
' Selection.AutoFilter
'
' Eliminar linhas em branco
'
' Range("A2:AD5000").Select
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
' Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
' xlSortNormal
' With ActiveWorkbook.Worksheets("Controle Processos").Sort
' .SetRange Range("A2:AD5000")
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
' Copiar dados
'
'
' Range("A1").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Check").Select
' Range("D10").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'
' Windows("Requerimentos Pendentes-Erik.xlsx").Activate
' Sheets("Controle Processos").Select
' Range("A3:AD50000").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Controle Processos").Select
' Range("B5").Select
' Selection.End(xlDown).Select
' ActiveCell.Offset(1, 0).Range("A1").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
' Windows("Requerimentos Pendentes-Erik.xlsx").Activate
' ActiveWindow.Close
'
'
' Copiar banco de dados - Requerimentos Pendentes-Mayra.xlsx
'
' Workbooks.Open Filename:= _
' "Z:_MICompradores_Planilhas Req PendRequerimentos Pendentes-Mayra.xlsx"
' Sheets("Controle Processos").Select
' Rows("2:2").Select
' Selection.AutoFilter
'
' Eliminar linhas em branco
'
' Range("A2:AD5000").Select
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
' Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
' xlSortNormal
' With ActiveWorkbook.Worksheets("Controle Processos").Sort
' .SetRange Range("A2:AD5000")
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
' Copiar dados
'
' Range("A1").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Check").Select
' Range("D11").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'
' Windows("Requerimentos Pendentes-Mayra.xlsx").Activate
' Sheets("Controle Processos").Select
' Range("A3:AD50000").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Controle Processos").Select
' Range("B5").Select
' Selection.End(xlDown).Select
' ActiveCell.Offset(1, 0).Range("A1").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
' Windows("Requerimentos Pendentes-Mayra.xlsx").Activate
' ActiveWindow.Close
'
'
' Copiar banco de dados - Requerimentos Pendentes-Ricardo.xlsx
'
' Workbooks.Open Filename:= _
' "Z:_MICompradores_Planilhas Req PendRequerimentos Pendentes-Ricardo.xlsx"
' Sheets("Controle Processos").Select
' Rows("2:2").Select
' Selection.AutoFilter
'
' Eliminar linhas em branco
'
' Range("A2:AD5000").Select
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
' Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
' xlSortNormal
' With ActiveWorkbook.Worksheets("Controle Processos").Sort
' .SetRange Range("A2:AD5000")
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
' Copiar dados
'
' Range("A1").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Check").Select
' Range("D12").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'
' Windows("Requerimentos Pendentes-Ricardo.xlsx").Activate
' Sheets("Controle Processos").Select
' Range("A3:AD50000").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Controle Processos").Select
' Range("B5").Select
' Selection.End(xlDown).Select
' ActiveCell.Offset(1, 0).Range("A1").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
' Windows("Requerimentos Pendentes-Ricardo.xlsx").Activate
' ActiveWindow.Close
'
'
' Copiar banco de dados - Requerimentos Pendentes-Vagner.xlsx
'
' Workbooks.Open Filename:= _
' "Z:_MICompradores_Planilhas Req PendRequerimentos Pendentes-Vagner.xlsx"
' Sheets("Controle Processos").Select
' Rows("2:2").Select
' Selection.AutoFilter
'
' Eliminar linhas em branco
'
' Range("A2:AD5000").Select
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
' Range("A3:A5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
' xlSortNormal
' With ActiveWorkbook.Worksheets("Controle Processos").Sort
' .SetRange Range("A2:AD5000")
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
' Copiar dados
'
' Range("A1").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Check").Select
' Range("D13").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'
' Windows("Requerimentos Pendentes-Vagner.xlsx").Activate
' Sheets("Controle Processos").Select
' Range("A3:AD50000").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Controle Processos").Select
' Range("B5").Select
' Selection.End(xlDown).Select
' ActiveCell.Offset(1, 0).Range("A1").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
' Windows("Requerimentos Pendentes-Vagner.xlsx").Activate
' ActiveWindow.Close

'
'
' Copiar bando de dados - Requerimentos Pendentes-Wellington.xlsx
'
' Workbooks.Open Filename:= _
' "Z:_MICompradores_Planilhas Req PendRequerimentos Pendentes-Wellington.xlsx"
' Sheets("Controle Processos").Select
' Rows("2:2").Select
' Selection.AutoFilter
'
' Eliminar linhas em branco
'
' Range("A2:AD7000").Select
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
' Range("A3:A7000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
' xlSortNormal
' With ActiveWorkbook.Worksheets("Controle Processos").Sort
' .SetRange Range("A2:AD7000")
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
' Copiar dados
'
' Range("A1").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Check").Select
' Range("D14").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'
' Windows("Requerimentos Pendentes-Wellington.xlsx").Activate
' Sheets("Controle Processos").Select
' Range("A3:AD50000").Select
' Selection.Copy
' Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
' Sheets("Controle Processos").Select
' Range("B5").Select
' Selection.End(xlDown).Select
' ActiveCell.Offset(1, 0).Range("A1").Select
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
' Windows("Requerimentos Pendentes-Wellington.xlsx").Activate
' ActiveWindow.Close
'
'
' Colocar requerimentos em ordem crescente
'
Windows("Requerimentos Pendentes-Matriz.xlsb").Activate
Sheets("Controle Processos").Select
Range("B4:AE7000").Select
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Controle Processos").Sort.SortFields.Add Key:= _
Range("B5:B7000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Controle Processos").Sort
.SetRange Range("B4:AE7000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
'
' Inserir filtro
'
Sheets("Controle Processos").Select
Rows("4:4").Select
Selection.AutoFilter
Range("C5").Select
'
'
' Ir para pasta check, ligar cálculo automático e salvar
'
Sheets("Check").Select
Range("B2").Select
Application.Calculation = xlAutomatic
ActiveWorkbook.Save

Application.ScreenUpdating = True
End Sub

 
Postado : 19/09/2017 12:53 pm
brunoxro
(@brunoxro)
Posts: 698
Honorable Member
 

Boa tarde,

Anexe uma planilha de exemplo, assim fica mais fácil tentar ajudar.

att,

 
Postado : 21/09/2017 2:31 pm