SZTM_Zahlliste.bas 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. Attribute VB_Name = "Module1"
  2. Sub SZTM_Zahlliste()
  3. Attribute SZTM_Zahlliste.VB_Description = "Formatiert die Zahlliste"
  4. Attribute SZTM_Zahlliste.VB_ProcData.VB_Invoke_Func = "F\n14"
  5. '
  6. ' SZTM_Zahlliste Macro
  7. ' Formatiert die Zahlliste
  8. '
  9. ' Keyboard Shortcut: Ctrl+Shift+F
  10. '
  11. Dim ws As Worksheet
  12. For Each ws In ActiveWorkbook.Sheets
  13. With ws
  14. ws.Activate
  15. 'Select first row, change font size, make bold and merge
  16. Range("A1:F1").Select
  17. With Selection
  18. .HorizontalAlignment = xlLeft
  19. .VerticalAlignment = xlBottom
  20. .WrapText = False
  21. .Orientation = 0
  22. .AddIndent = False
  23. .IndentLevel = 0
  24. .ShrinkToFit = False
  25. .ReadingOrder = xlContext
  26. .MergeCells = True
  27. End With
  28. Selection.Merge
  29. With Selection.Font
  30. .Name = "Calibri"
  31. .Size = 14
  32. .Strikethrough = False
  33. .Superscript = False
  34. .Subscript = False
  35. .OutlineFont = False
  36. .Shadow = False
  37. .Underline = xlUnderlineStyleNone
  38. .ThemeColor = xlThemeColorLight1
  39. .TintAndShade = 0
  40. .ThemeFont = xlThemeFontMinor
  41. End With
  42. Selection.Font.Bold = True
  43. 'Select second row, make bold and merge
  44. Range("A2:F2").Select
  45. With Selection
  46. .HorizontalAlignment = xlLeft
  47. .VerticalAlignment = xlBottom
  48. .WrapText = False
  49. .Orientation = 0
  50. .AddIndent = False
  51. .IndentLevel = 0
  52. .ShrinkToFit = False
  53. .ReadingOrder = xlContext
  54. .MergeCells = True
  55. End With
  56. Selection.Merge
  57. Selection.Font.Bold = True
  58. 'Select price cells and merge
  59. Range("C4:F4").Select
  60. Selection.Merge
  61. 'Select last cell
  62. ActiveCell.SpecialCells(xlLastCell).Select
  63. Selection.Offset(0, -2).Select
  64. Selection.Resize(Selection.Rows.Count + 1, Selection.Columns.Count + 2).Select
  65. Selection.Merge
  66. Selection.Offset(0, -3).Select
  67. Selection.Resize(Selection.Rows.Count + 1, Selection.Columns.Count + 2).Select
  68. Selection.Merge
  69. Selection.Offset(-1, 0).Select
  70. Selection.Font.Bold = True
  71. Selection.Offset(0, 1).Select
  72. Selection.Resize(Selection.Rows.Count, Selection.Columns.Count + 1).Select
  73. Selection.Merge
  74. Selection.Offset(0, 1).Select
  75. Selection.Font.Bold = True
  76. Selection.Offset(0, 1).Select
  77. Selection.Resize(Selection.Rows.Count, Selection.Columns.Count + 1).Select
  78. Selection.Merge
  79. Selection.Offset(-1, -4).Select
  80. Selection.Font.Bold = True
  81. Selection.Offset(0, 1).Select
  82. Selection.Resize(Selection.Rows.Count, Selection.Columns.Count + 1).Select
  83. Selection.Merge
  84. Selection.Offset(0, -1).Select
  85. Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
  86. Selection.Resize(Selection.Rows.Count - 1, Selection.Columns.Count).Select
  87. Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  88. Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  89. With Selection.Borders(xlEdgeLeft)
  90. .LineStyle = xlContinuous
  91. .ColorIndex = 0
  92. .TintAndShade = 0
  93. .Weight = xlThin
  94. End With
  95. With Selection.Borders(xlEdgeTop)
  96. .LineStyle = xlContinuous
  97. .ColorIndex = 0
  98. .TintAndShade = 0
  99. .Weight = xlThin
  100. End With
  101. With Selection.Borders(xlEdgeBottom)
  102. .LineStyle = xlContinuous
  103. .ColorIndex = 0
  104. .TintAndShade = 0
  105. .Weight = xlThin
  106. End With
  107. With Selection.Borders(xlEdgeRight)
  108. .LineStyle = xlContinuous
  109. .ColorIndex = 0
  110. .TintAndShade = 0
  111. .Weight = xlThin
  112. End With
  113. With Selection.Borders(xlInsideVertical)
  114. .LineStyle = xlContinuous
  115. .ColorIndex = 0
  116. .TintAndShade = 0
  117. .Weight = xlThin
  118. End With
  119. With Selection.Borders(xlInsideHorizontal)
  120. .LineStyle = xlContinuous
  121. .ColorIndex = 0
  122. .TintAndShade = 0
  123. .Weight = xlThin
  124. End With
  125. 'Select all data cells, activate grid, fit width, increase height and add header.
  126. Range("A6:F6").Select
  127. With Selection.Interior
  128. .Pattern = xlSolid
  129. .PatternColorIndex = xlAutomatic
  130. .ThemeColor = xlThemeColorDark1
  131. .TintAndShade = -0.149998474074526
  132. .PatternTintAndShade = 0
  133. End With
  134. Selection.Font.Bold = True
  135. ActiveWindow.SmallScroll Down:=-3
  136. Range("A6").Select
  137. Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
  138. Selection.Resize(Selection.Rows.Count - 6, Selection.Columns.Count).Select
  139. Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  140. Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  141. With Selection.Borders(xlEdgeLeft)
  142. .LineStyle = xlContinuous
  143. .ColorIndex = 0
  144. .TintAndShade = 0
  145. .Weight = xlThin
  146. End With
  147. With Selection.Borders(xlEdgeTop)
  148. .LineStyle = xlContinuous
  149. .ColorIndex = 0
  150. .TintAndShade = 0
  151. .Weight = xlThin
  152. End With
  153. With Selection.Borders(xlEdgeBottom)
  154. .LineStyle = xlContinuous
  155. .ColorIndex = 0
  156. .TintAndShade = 0
  157. .Weight = xlThin
  158. End With
  159. With Selection.Borders(xlEdgeRight)
  160. .LineStyle = xlContinuous
  161. .ColorIndex = 0
  162. .TintAndShade = 0
  163. .Weight = xlThin
  164. End With
  165. With Selection.Borders(xlInsideVertical)
  166. .LineStyle = xlContinuous
  167. .ColorIndex = 0
  168. .TintAndShade = 0
  169. .Weight = xlThin
  170. End With
  171. With Selection.Borders(xlInsideHorizontal)
  172. .LineStyle = xlContinuous
  173. .ColorIndex = 0
  174. .TintAndShade = 0
  175. .Weight = xlThin
  176. End With
  177. Selection.RowHeight = 33.75
  178. Selection.EntireColumn.AutoFit
  179. 'Columns("A:A").EntireColumn.AutoFit
  180. 'Columns("B:B").EntireColumn.AutoFit
  181. 'Columns("C:C").EntireColumn.AutoFit
  182. 'Columns("D:D").EntireColumn.AutoFit
  183. 'Columns("E:E").EntireColumn.AutoFit
  184. End With
  185. Next
  186. End Sub