Mauro,
Obrigado pela ajuda.
Consegui arrumar a macro.
Ficou da seguinte forma.
"Sub balancete_consolidado()
Application.ScreenUpdating = False
balancete
baldimensao
ActiveWorkbook.Names.Add Name:="resumo", RefersTo:= _
"=resumo!$a$5:$z$59900"
ActiveWorkbook.Names.Add Name:="ultima_linha_resumo", RefersTo:= _
"=CONT.valores(resumo!$a$5:$a$59900)"
ActiveWorkbook.Names.Add Name:="ultima_coluna_resumo", RefersTo:= _
"=CONT.valores(resumo!$D$3:$z$3)"
ActiveWorkbook.Names.Add Name:="sel_resumo", RefersTo:= _
"=desloc(resumo;0;3;ultima_linha_resumo;ultima_coluna_resumo)"
ActiveWorkbook.Names.Add Name:="sel_resumo", RefersToR1C1:= _
"=desloc(resumo;0;3;ultima_linha_resumo;ultima_coluna_resumo)"
ActiveWorkbook.Names.Add Name:="contas_resumo", RefersTo:= _
"=resumo!$a$5:$a$59900"
ActiveWorkbook.Names.Add Name:="bal_resumo", RefersTo:= _
"=resumo!$a$5:$C$59900"
ActiveWorkbook.Names.Add Name:="sel_bal_resumo", RefersTo:= _
"=desloc(bal_resumo;0;0;ultima_linha_resumo)"
ActiveWorkbook.Names.Add Name:="sel_bal_resumo", RefersToR1C1:= _
"=desloc(bal_resumo;0;0;ultima_linha_resumo)"
Macro2
Windows("ABAAN_ESv2.xls").Activate
Sheets("resumo").Select
Range("D5").Select
ActiveCell.FormulaR1C1 = _
"=+SUMIF(bald!C19,TRIM(CONCATENATE(MID(R3C,1,5),""_/_"",LEFT(RC1,7))),bald!C12)"
Selection.Copy
Range("sel_resumo").Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Windows("ABAAN_ESv2.xls").Activate
Sheets("resumo").Select
Range("D3").Select
ActiveCell.End(xlToRight).Select
Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
ActiveCell.FormulaR1C1 = "MATRIZ"
Cells(ActiveCell.Row + 2, ActiveCell.Column).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(contas_resumo,bal!R3C1:R59900C11,10,0)-SUM(RC4:RC[-1])"
ActiveCell.Select
Selection.Copy
Cells(ActiveCell.Row, ActiveCell.Column - 1).Select
ActiveCell.End(xlDown).Select
Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
Range(ActiveCell, ActiveCell.End(xlUp)).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("D3").Select
ActiveCell.End(xlToRight).Select
Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
ActiveCell.FormulaR1C1 = "TOTAL"
Cells(ActiveCell.Row + 2, ActiveCell.Column).Select
ActiveCell.FormulaR1C1 = "=SUM(RC4:RC[-1])"
ActiveCell.Select
Selection.Copy
Cells(ActiveCell.Row, ActiveCell.Column - 1).Select
ActiveCell.End(xlDown).Select
Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
Range(ActiveCell, ActiveCell.End(xlUp)).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("D5:Z60000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("sel_resumo").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Range("sel_bal_resumo").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 11
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("A1").Select
Range("A4:Z4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="<>0", Operator:=xlAnd
Rows("5:65536").Select
Selection.Font.Bold = True
Selection.AutoFilter Field:=2
Selection.AutoFilter
Range("D5").Select
ActiveWindow.FreezePanes = True
Range("A1").Select
Sheets("resumo").Select
Sheets("resumo").Copy
Range("D1").Select
Selection.ClearContents
Range("A1").Select
Application.Dialogs(xlDialogSaveAs).Show
ActiveWindow.ActivateNext
Módulo1.home2
End Sub"
Obrigado a todos pela ajuda.
Att,
Luís