Ola Pessoal,
Bom dia.
Gostaria de saber como faço para executar a Macro abaixo para todas as planilhas que tenho no arquivo, independente do nomes das Plans.
Percebam que em algumas linhas, a Macro informa o nome da Plan (01.04.2015), só que esse arquivo terá varias planilhas com nomes diferentes, e quero executar essa Macro em todas elas.
É uma Macro de formatação.
Sub arrumar()
'
' arrumar Macro
'
'
Selection.CurrentRegion.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Font.Bold = True
Selection.CurrentRegion.Select
ActiveWorkbook.Worksheets("01.04.2015").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("01.04.2015").Sort.SortFields.Add Key:=Range( _
"F2:F27"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("01.04.2015").Sort.SortFields.Add Key:=Range( _
"H2:H27"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("01.04.2015").Sort.SortFields.Add Key:=Range( _
"G2:G27"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("01.04.2015").Sort
.SetRange Range("A1:H27")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("H1").Select
Selection.End(xlDown).Select
Range("H28").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-26]C:R[-1]C)"
Columns("H:H").Select
Selection.NumberFormat = "$ #,##0.00"
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("H1").Select
Selection.End(xlDown).Select
Selection.Font.Bold = True
Range("G28").Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Clear
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlToLeft).Select
Cells.Select
Cells.EntireColumn.AutoFit
Selection.End(xlUp).Select
End Sub
Obrigado.
Postado : 02/04/2015 7:48 am