Ao executar a macro abaixo, ela executa todo o loop, porém no final aparece a mensagem "Erro em tempo de execução 91: A variável do objeto ou a variável do bloco 'With' não foi definida"
Sub MacroLocalizar_e_Fixar()
'
Selection.AutoFill Destination:=ActiveCell.Range("A1:A2"), Type:=xlFillDefault
Dim Total As Integer
Última_linha_Preenchida = Range("a1048576").End(xlUp).Row - 1
' Range("A1").Select
Rows(Última_linha_Preenchida + 1).Insert shift:=x1down
ActiveCell.Offset(Última_linha_Preenchida + 3, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "Final"
Linha = 1
Do Until Cells(Linha, 1) = "Final"
Columns("A:A").Select
Selection.Find(What:="Total", After:=ActiveCell, LookIn:=xlFormulas2, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 0).Select
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
' Sub Macro_Negrito
Selection.Font.Bold = True
' Sub Macro_Ajeitar_Posição
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
' Sub Macro_Apagar_Coluna_1()
ActiveCell.Offset(0, -3).Range("A1").Select
Selection.ClearContents
' Sub Macro_Mudar_Linha_e_Copiar
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
' Sub Macro_Negrito
Selection.Font.Bold = True
' Sub Macro_Ajeitar_Posição
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
' Sub Macro_Apagar_Coluna_1()
ActiveCell.Offset(0, -3).Range("A1").Select
Selection.ClearContents
' Sub Macro_Mudar_Linha_e_Copiar
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
' Sub Macro_Negrito
Selection.Font.Bold = True
' Sub Macro_Ajeitar_Posição
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
' Sub Macro_Apagar_Coluna_1()
ActiveCell.Offset(0, -3).Range("A1").Select
Selection.ClearContents
Loop
End Sub