Advertisement
Robb1010

Arrange all VBA

Nov 15th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Arrange_stuff()
  2. '
  3. ' Arrange_stuff Macro
  4. '
  5. ' Keyboard Shortcut: Ctrl+Shift+A
  6. '
  7.  
  8. ActiveWorkbook.CheckCompatibility = False
  9.  
  10.     Range("A1").Select
  11.     If Application.CountA(ActiveCell.EntireRow) = 0 Then
  12.      Worksheets("Sheet1").Rows("1:4").Delete
  13. End If
  14.                        
  15.     Cells.Select
  16.     With Selection.Font
  17.         .Name = "Calibri"
  18.         .Size = 10
  19.         .Strikethrough = False
  20.         .Superscript = False
  21.         .Subscript = False
  22.         .OutlineFont = False
  23.         .Shadow = False
  24.         .Underline = xlUnderlineStyleNone
  25.         .ColorIndex = 1
  26.         .TintAndShade = 0
  27.         .ThemeFont = xlThemeFontMinor
  28.     End With
  29.     Selection.Columns.AutoFit
  30.     Selection.Rows.AutoFit
  31.    
  32.     Range(Range("A1"), Range("A1").End(xlDown)).Select
  33.     numRows = Selection.Count
  34.    
  35.     Range("A" & numRows).Cut Range("A" & numRows + 1)
  36.     Application.CutCopyMode = False
  37.    
  38.     Rows(numRows).Delete
  39.     Rows(numRows + 1 & ":" & numRows + 5).Delete
  40.    
  41.    
  42.     Dim C As Integer
  43.     C = Worksheets("Sheet1").Cells.SpecialCells(xlLastCell).Column
  44.     Do Until C = 0
  45.     If WorksheetFunction.CountA(Columns(C)) = 0 Then
  46.     Columns(C).Delete
  47.     End If
  48.     C = C - 1
  49.     Loop
  50.     Dim ColumnLetter As String
  51.     LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
  52.     ColumnLetter = Split(Cells(1, LastColumn).Address, "$")(1)
  53.    
  54.     If Range("A" & numRows - 1) = "TOTAL" Then
  55.         numRows = numRows - 1
  56.         Rows(numRows + 1).Delete
  57.     End If
  58.    
  59.     Worksheets("Sheet1").ListObjects.Add(xlSrcRange, Range("A1:" & ColumnLetter & numRows - 1), , xlYes).Name = _
  60.          "Table1"
  61.            
  62.     Range("A1:" & ColumnLetter & numRows - 1).Select
  63.     Worksheets("Sheet1").ListObjects("Table1").TableStyle = "TableStyleLight8"
  64.     Range("A1:" & ColumnLetter & numRows).Select
  65.     Selection.NumberFormat = "0.00"
  66.    
  67.     'Borders
  68.    
  69.     With Selection.Borders(xlEdgeLeft)
  70.         .LineStyle = xlContinuous
  71.         .ColorIndex = 0
  72.         .TintAndShade = 0
  73.         .Weight = xlThin
  74.     End With
  75.     With Selection.Borders(xlEdgeTop)
  76.         .LineStyle = xlContinuous
  77.         .ColorIndex = 0
  78.         .TintAndShade = 0
  79.         .Weight = xlThin
  80.     End With
  81.     With Selection.Borders(xlEdgeBottom)
  82.         .LineStyle = xlContinuous
  83.         .ColorIndex = 0
  84.         .TintAndShade = 0
  85.         .Weight = xlThin
  86.     End With
  87.     With Selection.Borders(xlEdgeRight)
  88.         .LineStyle = xlContinuous
  89.         .ColorIndex = 0
  90.         .TintAndShade = 0
  91.         .Weight = xlThin
  92.     End With
  93.     With Selection.Borders(xlInsideVertical)
  94.         .LineStyle = xlContinuous
  95.         .ColorIndex = 0
  96.         .TintAndShade = 0
  97.         .Weight = xlThin
  98.     End With
  99.     With Selection.Borders(xlInsideHorizontal)
  100.         .LineStyle = xlContinuous
  101.         .ColorIndex = 0
  102.         .TintAndShade = 0
  103.         .Weight = xlThin
  104.     End With
  105.     With Selection.Font
  106.         .Name = "Calibri"
  107.         .Size = 10
  108.         .Strikethrough = False
  109.         .Superscript = False
  110.         .Subscript = False
  111.         .OutlineFont = False
  112.         .Shadow = False
  113.         .Underline = xlUnderlineStyleNone
  114.         .ColorIndex = 1
  115.         .TintAndShade = 0
  116.         .ThemeFont = xlThemeFontMinor
  117.     End With
  118.    
  119.     'Colors
  120.    
  121.     Range("A1:" & ColumnLetter & "1").Select
  122.      With Selection.Interior
  123.         .Pattern = xlSolid
  124.         .PatternColorIndex = xlAutomatic
  125.         .ThemeColor = xlThemeColorDark1
  126.         .TintAndShade = -0.249977111117893
  127.         .PatternTintAndShade = 0
  128.      End With
  129.         With Selection.Font
  130.         .ThemeColor = xlThemeColorLight1
  131.         .TintAndShade = 0
  132.         .Bold = True
  133.     End With
  134.     Range("A" & numRows & ":" & ColumnLetter & numRows).Select
  135.     With Selection.Interior
  136.         .Pattern = xlSolid
  137.         .PatternColorIndex = xlAutomatic
  138.         .ThemeColor = xlThemeColorDark1
  139.         .TintAndShade = -0.249977111117893
  140.         .PatternTintAndShade = 0
  141.      End With
  142.         With Selection.Font
  143.         .ThemeColor = xlThemeColorLight1
  144.         .TintAndShade = 0
  145.         .Bold = True
  146.     End With
  147.  
  148. Range("A2").Select
  149.  
  150.  
  151. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement