costalat

VBA - sort and format excel data

Sep 7th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Macro6()
  2. '
  3. ' Ordenar universo de OT's e formatar a tabela de saĆ­da
  4. '
  5. ' Atalho por teclado: Ctrl+w
  6. '
  7.  
  8.  Dim tamanho As Variant
  9.  Dim tamanhot As Variant
  10.  
  11.  tamanho = Range("A65536").End(xlUp).Row
  12.  Worksheets("Folha1").Range(Cells(16, 1), Cells(tamanho, 5)).Sort Key1:=Worksheets("Folha1").Columns("E"), Order1:=xlAscending
  13.  
  14.  If tamanho < 51 Then
  15.   Range("C51").Select
  16.     ActiveCell.FormulaR1C1 = "O XXXXXXX"
  17.     Range("C52").Select
  18.     ActiveCell.FormulaR1C1 = "_______________"
  19.     Range("C53").Select
  20.     ActiveCell.FormulaR1C1 = "__________"
  21.  
  22.     Range("C51:c53").Select
  23.     With Selection
  24.         .HorizontalAlignment = xlCenter
  25.         .VerticalAlignment = xlBottom
  26.         .WrapText = False
  27.         .Orientation = 0
  28.         .AddIndent = False
  29.         .IndentLevel = 0
  30.         .ShrinkToFit = False
  31.         .ReadingOrder = xlContext
  32.         .MergeCells = False
  33.     End With
  34.    
  35.     Else
  36.    
  37.     tamanho = Range("D65536").End(xlUp).Row
  38.     tamanho = tamanho + 4
  39.     Range(Cells(tamanho, 3), Cells(tamanho, 3)).Select
  40.     ActiveCell.FormulaR1C1 = "O XXXXXXX"
  41.     tamanho = tamanho + 1
  42.     Range(Cells(tamanho, 3), Cells(tamanho, 3)).Select
  43.     'Range("C52").Select
  44.    ActiveCell.FormulaR1C1 = "_______________"
  45.     tamanho = tamanho + 1
  46.     'Range("C53").Select
  47.    Range(Cells(tamanho, 3), Cells(tamanho, 3)).Select
  48.     ActiveCell.FormulaR1C1 = "__________"
  49.  
  50.     tamanhot = tamanho
  51.     tamanho = tamanho - 2
  52.     Range(Cells(tamanho, 3), Cells(tamanhot, 3)).Select
  53.     'Range("C51:c53").Select
  54.    With Selection
  55.         .HorizontalAlignment = xlCenter
  56.         .VerticalAlignment = xlBottom
  57.         .WrapText = False
  58.         .Orientation = 0
  59.         .AddIndent = False
  60.         .IndentLevel = 0
  61.         .ShrinkToFit = False
  62.         .ReadingOrder = xlContext
  63.         .MergeCells = False
  64.    
  65.     End With
  66.     End If
  67.     Range("A1").Activate
  68. End Sub
  69.  
  70. 'https://lh4.googleusercontent.com/-OGNs1yEAeYw/TmecKZgX9qI/AAAAAAAAA8E/US5nw3XNIN8/s1068/prioridades_3.jpg
  71. 'https://lh3.googleusercontent.com/-WVZpoB-RBBw/TmecNcA62UI/AAAAAAAAA8M/RQu5XOgt1Ug/s1072/prioridades_4.jpg
Advertisement
Add Comment
Please, Sign In to add comment