You are on page 1of 3

Sub Macro5()

'
' Macro5 Macro
'

'
Sheets("IDIV").Select
ActiveWorkbook.Worksheets("IDIV").ListObjects("Tabela1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("IDIV").ListObjects("Tabela1").Sort.SortFields.Add _
Key:=Range("Tabela1[[#All],[�ltimo Pre�o]]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("IDIV").ListObjects("Tabela1").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Sheets("IDIV").Select
Range("A6,B6,G6,H6,P6").Select
Range("G6").Activate
Selection.Copy
Sheets("Plan02").Select
Range("A2").Select

Do
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until ActiveCell = ""
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Columns("A:A").Select
Selection.NumberFormat = "d/m/yy h:mm;@"
ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort.SortFields.Add
_
Key:=Range("Tabela5[[#All],[Coluna1]]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("A2").Select
Selection.ListObject.ListRows.Add (1)
Selection.ListObject.ListRows.Add (1)

Call Temporizador
End With
End Sub

--------------------------------------

Sub Temporizador()
'Chama a rotina SuaMacro ap�s 01 minutos
Call Application.OnTime(Now + TimeSerial(0, 0,
Sheets("IDIV").Range("E1").Value), "Macro5")
Call apagarlinha
End Sub

------------------------------------

Sub apagarlinha()
'
' apagarlinha Macro
'

'

Sheets("Plan02").Select
ActiveSheet.ListObjects("Tabela5").Range.AutoFilter Field:=4, Criteria1:= _
"<>"
ActiveSheet.Range("D2", ActiveSheet.Range("D2").End(xlDown)).Select
Selection.EntireRow.Delete
ActiveSheet.ListObjects("Tabela5").Range.AutoFilter Field:=4
Range("D2").Select
Selection.ListObject.ListRows.Add (1)
Selection.ListObject.ListRows.Add (1)

Sheets("Plan02").Select
ActiveSheet.ListObjects("Tabela5").Range.AutoFilter Field:=4, Criteria1:= _
"#N/D"
ActiveSheet.Range("D2", ActiveSheet.Range("D2").End(xlDown)).Select
Selection.EntireRow.Delete
ActiveSheet.ListObjects("Tabela5").Range.AutoFilter Field:=4
Range("D2").Select
Selection.ListObject.ListRows.Add (1)
Selection.ListObject.ListRows.Add (1)

ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort.SortFields.Add
_
Key:=Range("Tabela5[[#All],[Coluna1]]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Plan02").ListObjects("Tabela5").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

End Sub

-----------------------------------------

Private Sub Workbook_Open()

Call Macro5
Call Shell("C:\Program Files\Octo Investimentos\Rico
RTD\LHB.APP.QuoteClient.exe", 1)
End Sub

You might also like