Advertisement
veronikaaa86

exam_final

Jan 29th, 2022
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. Sub Main()
  2. Dim lastRow As Integer
  3. lastRow = Cells(Rows.Count, 1).End(xlUp).Row
  4.  
  5. InsertNewColumn
  6. SplitName (lastRow)
  7. DeleteColumn
  8. ExperiencePlus (lastRow)
  9. GrossSalary (lastRow)
  10. Calculations (lastRow)
  11. AvgAndSum
  12. PercentAvgSalary (lastRow)
  13. Formatting (lastRow)
  14.  
  15. End Sub
  16.  
  17. Sub InsertNewColumn()
  18. Columns("B:B").Select
  19. Selection.Insert Shift:=xlToRight
  20. Selection.Insert Shift:=xlToRight
  21. Range("B1").Select
  22. ActiveCell.FormulaR1C1 = "Име"
  23. Range("C1").Select
  24. ActiveCell.FormulaR1C1 = "Фамилия"
  25. Range("A1").Select
  26. End Sub
  27.  
  28. Sub SplitName(lastRow As Integer)
  29. Dim fullName, firstName, lastName As String
  30.  
  31. For i = 2 To lastRow
  32. fullName = Range("A" & i)
  33.  
  34. Dim splitedName As Variant
  35. splitedName = Split(fullName, " ")
  36.  
  37. Range("B" & i) = splitedName(0)
  38. Range("C" & i) = splitedName(1)
  39. Next
  40. End Sub
  41.  
  42. Sub DeleteColumn()
  43. Columns("A:A").Select
  44. Selection.Delete Shift:=xlToLeft
  45. Range("A1").Select
  46. End Sub
  47.  
  48. Sub ExperiencePlus(lastRow As Integer)
  49. For i = 2 To lastRow
  50. Dim baseSalary, experienceAge As Double
  51. baseSalary = Range("E" & i)
  52. experienceAge = Range("D" & i)
  53.  
  54. If experienceAge >= 3 Then
  55. 'Range("F" & i) = experienceAge * (baseSalary * 0.006)
  56. Range("F" & i) = "=D" & i & "*(E" & i & "*0.006)"
  57. Else
  58. Range("F" & i) = 0
  59. End If
  60. Next
  61. End Sub
  62.  
  63. Sub GrossSalary(lastRow As Integer)
  64. For i = 2 To lastRow
  65. Range("G" & i) = "=E" & i & "+F" & i
  66. Next
  67. End Sub
  68.  
  69. Sub Calculations(lastRow As Integer)
  70. For i = 2 To lastRow
  71. Range("H" & i) = "=G" & i & "*0.224"
  72. Range("I" & i) = "=G" & i & "- H" & i
  73. Range("K" & i) = "=G" & i & "*0.189"
  74. Range("L" & i) = "=G" & i & "+ K" & i
  75. Next
  76. End Sub
  77.  
  78. Sub AvgAndSum()
  79. Range("A60:H60").Select
  80. With Selection
  81. .HorizontalAlignment = xlCenter
  82. .VerticalAlignment = xlBottom
  83. .ReadingOrder = xlContext
  84. End With
  85. Selection.Merge
  86. ActiveCell.FormulaR1C1 = "Средно"
  87. Range("A60:H60").Select
  88. With Selection
  89. .HorizontalAlignment = xlRight
  90. .VerticalAlignment = xlBottom
  91. .ReadingOrder = xlContext
  92. .MergeCells = True
  93. End With
  94. Range("I60").Select
  95. Application.CutCopyMode = False
  96. ActiveCell.FormulaR1C1 = "=AVERAGE(R[-58]C:R[-1]C)"
  97. Range("I61").Select
  98. ActiveWindow.SmallScroll Down:=3
  99. Range("J60:K60").Select
  100. With Selection
  101. .HorizontalAlignment = xlCenter
  102. .VerticalAlignment = xlBottom
  103. .ReadingOrder = xlContext
  104. End With
  105. Selection.Merge
  106. With Selection
  107. .HorizontalAlignment = xlRight
  108. .VerticalAlignment = xlBottom
  109. .ReadingOrder = xlContext
  110. .MergeCells = True
  111. End With
  112. ActiveCell.FormulaR1C1 = "Общо"
  113. Range("L60").Select
  114. Application.CutCopyMode = False
  115. ActiveCell.FormulaR1C1 = "=SUM(R[-58]C:R[-1]C)"
  116. Range("L61").Select
  117. End Sub
  118.  
  119. Sub PercentAvgSalary(lastRow As Integer)
  120. For i = 2 To lastRow
  121. Range("J" & i) = "=(I" & i & "- $I$" & lastRow + 1 & ") / $I$" & lastRow + 1
  122. Next
  123. End Sub
  124.  
  125. Sub Formatting(lastRow As Integer)
  126. Rows("1:1").Select
  127. Selection.Insert Shift:=xlDown
  128. Range("A1:L1").Select
  129. With Selection
  130. .HorizontalAlignment = xlCenter
  131. .VerticalAlignment = xlBottom
  132. .WrapText = False
  133. .Orientation = 0
  134. .AddIndent = False
  135. .IndentLevel = 0
  136. .ShrinkToFit = False
  137. .ReadingOrder = xlContext
  138. .MergeCells = False
  139. End With
  140. Selection.Merge
  141. ActiveCell.FormulaR1C1 = "Служители на трудов договор - извадка"
  142. Range("A1:L1").Select
  143. With Selection.Interior
  144. .Pattern = xlSolid
  145. .PatternColorIndex = xlAutomatic
  146. .ThemeColor = xlThemeColorLight2
  147. .TintAndShade = 0
  148. .PatternTintAndShade = 0
  149. End With
  150. With Selection.Font
  151. .ThemeColor = xlThemeColorDark1
  152. .TintAndShade = 0
  153. End With
  154. Selection.Font.Bold = True
  155. With Selection.Interior
  156. .Pattern = xlSolid
  157. .PatternColorIndex = xlAutomatic
  158. .ThemeColor = xlThemeColorAccent1
  159. .TintAndShade = 0
  160. .PatternTintAndShade = 0
  161. End With
  162. Selection.Font.Size = 12
  163. Selection.Font.Size = 14
  164. Selection.Font.Size = 16
  165. Selection.Font.Size = 18
  166. Selection.Font.Size = 20
  167. Range("A2:L2").Select
  168. With Selection
  169. .HorizontalAlignment = xlCenter
  170. .WrapText = False
  171. .Orientation = 0
  172. .AddIndent = False
  173. .IndentLevel = 0
  174. .ShrinkToFit = False
  175. .ReadingOrder = xlContext
  176. .MergeCells = False
  177. End With
  178. With Selection
  179. .HorizontalAlignment = xlCenter
  180. .VerticalAlignment = xlCenter
  181. .WrapText = False
  182. .Orientation = 0
  183. .AddIndent = False
  184. .IndentLevel = 0
  185. .ShrinkToFit = False
  186. .ReadingOrder = xlContext
  187. .MergeCells = False
  188. End With
  189. Selection.Font.Bold = True
  190. With Selection
  191. .HorizontalAlignment = xlCenter
  192. .VerticalAlignment = xlCenter
  193. .WrapText = True
  194. .Orientation = 0
  195. .AddIndent = False
  196. .IndentLevel = 0
  197. .ShrinkToFit = False
  198. .ReadingOrder = xlContext
  199. .MergeCells = False
  200. End With
  201. ActiveWindow.SmallScroll Down:=39
  202. Range("A61:H61,J61:K61").Select
  203. Range("J61").Activate
  204. With Selection.Interior
  205. .Pattern = xlSolid
  206. .PatternColorIndex = xlAutomatic
  207. .ThemeColor = xlThemeColorAccent1
  208. .TintAndShade = 0
  209. .PatternTintAndShade = 0
  210. End With
  211. With Selection.Font
  212. .ThemeColor = xlThemeColorDark1
  213. .TintAndShade = 0
  214. End With
  215. Selection.Font.Bold = True
  216. Range("I61,L61").Select
  217. Range("L61").Activate
  218. Selection.Font.Bold = True
  219. With Selection.Font
  220. .ThemeColor = xlThemeColorDark1
  221. .TintAndShade = 0
  222. End With
  223. With Selection.Interior
  224. .Pattern = xlSolid
  225. .PatternColorIndex = xlAutomatic
  226. .ThemeColor = xlThemeColorLight1
  227. .TintAndShade = 0.499984740745262
  228. .PatternTintAndShade = 0
  229. End With
  230. Range("A1:L61").Select
  231. Range("A61").Activate
  232. Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  233. Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  234. With Selection.Borders(xlEdgeLeft)
  235. .LineStyle = xlContinuous
  236. .ColorIndex = 0
  237. .TintAndShade = 0
  238. .Weight = xlThin
  239. End With
  240. With Selection.Borders(xlEdgeTop)
  241. .LineStyle = xlContinuous
  242. .ColorIndex = 0
  243. .TintAndShade = 0
  244. .Weight = xlThin
  245. End With
  246. With Selection.Borders(xlEdgeBottom)
  247. .LineStyle = xlContinuous
  248. .ColorIndex = 0
  249. .TintAndShade = 0
  250. .Weight = xlThin
  251. End With
  252. With Selection.Borders(xlEdgeRight)
  253. .LineStyle = xlContinuous
  254. .ColorIndex = 0
  255. .TintAndShade = 0
  256. .Weight = xlThin
  257. End With
  258. With Selection.Borders(xlInsideVertical)
  259. .LineStyle = xlContinuous
  260. .ColorIndex = 0
  261. .TintAndShade = 0
  262. .Weight = xlThin
  263. End With
  264. With Selection.Borders(xlInsideHorizontal)
  265. .LineStyle = xlContinuous
  266. .ColorIndex = 0
  267. .TintAndShade = 0
  268. .Weight = xlThin
  269. End With
  270. ActiveWindow.SmallScroll Down:=-69
  271. Range("A1:L1").Select
  272. End Sub
  273.  
  274.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement