Advertisement
veronikaaa86

Protocol - All Sub

Jan 13th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1.  
  2.  
  3. Sub Main()
  4. 'StartUI.cb1_Click
  5. 'cb1_Click
  6.  
  7. 'Dim lastRow As Integer
  8. 'lastRow = Cells(Rows.Count, 1).End(xlUp).Row
  9.  
  10. 'StartUI.Show
  11.  
  12. 'Dim num As Integer
  13.  
  14. 'Sheets.Add(Before:=Sheets("Sheet0")).Name = "Protocol"
  15. 'CopyData
  16. 'InsertColumns
  17. 'FormatHeaders (lastRow)
  18.  
  19. 'PracticalAndThereticalPoints (lastRow)
  20. 'Dim percentPractical, percentTheoretical As Integer
  21. 'percentPractical = num
  22. 'percentPractical = Application.InputBox("Enter a percentage for a practical exam")
  23. 'percentTheoretical = Application.InputBox("Enter a percentage for a theoretical exam")
  24.  
  25. 'CoursePoints lastRow, percentPractical, percentTheoretical
  26. 'Grade (lastRow)
  27.  
  28. End Sub
  29.  
  30.  
  31. Function CoursePoints(lastRow, percentPractical, percentTheoretical As Integer)
  32. Dim isParticipate As Boolean
  33. For r = 2 To lastRow
  34. isNotParticipate = Range("D" & r) = "NO" And Range("E" & r) = "NO"
  35. If isNotParticipate Then
  36. Range("B" & r) = "Did not appear for the exam!"
  37. Else
  38. Range("B" & r) = _
  39. "=$D" & r & "*" & percentPractical & "/ 100 +" & " $E" & r & "*" & percentTheoretical & " / 100"
  40. End If
  41.  
  42. Next
  43. End Function
  44.  
  45. Sub PracticalAndThereticalPoints(lastRow As Integer)
  46. For r = 2 To lastRow
  47. Range("D" & r) = _
  48. "=VLOOKUP(A" & r & " ,'Practical Points'!A:B,2,FALSE)"
  49. Range("E" & r) = _
  50. "=VLOOKUP(A" & r & " ,'Theoretical Points'!A:B,2,FALSE)"
  51.  
  52. If Range("D" & r) = 0 And Range("E" & r) = 0 Then
  53. Range("D" & r) = "NO"
  54. Range("E" & r) = "NO"
  55. End If
  56. Next
  57. End Sub
  58.  
  59. Sub Grade(lastRow, pointsFor5, pointsFor3 As Integer)
  60. For r = 2 To lastRow
  61. value = Range("G" & r)
  62.  
  63. If Range("B" & r) = "Did not appear for the exam!" Then
  64. Range("C" & r) = ""
  65. ElseIf Range("B" & r) >= 100 And value Then
  66. Range("C" & r) = 6
  67. ElseIf Range("B" & r) <= pointsFor5 Then
  68. Range("C" & r) = "=3+2*(B" & r & "-" & pointsFor3 & ")/(" & pointsFor5 & "-" & pointsFor3 & ")"
  69. If Range("C" & r) <= 2 Then
  70. Range("C" & r) = 2
  71. End If
  72. Else
  73. 'Range("C" & r) = "=5+(B" & r & "-70)/(95-70)"
  74. Range("C" & r) = "=5+(B" & r & "-" & pointsFor5 & ")/(95-" & pointsFor5 & ")"
  75. End If
  76. Next
  77.  
  78. End Sub
  79.  
  80. Sub Statistics(allParticipants, lastRow As Integer)
  81.  
  82.  
  83. End Sub
  84.  
  85.  
  86. Function CopyData()
  87. Dim col, data As Variant
  88.  
  89. col = GetColAddress("Sheet0", "Username")
  90. If col = False Then
  91. MsgBox "Username not found"
  92. Else
  93. Sheets("Sheet0").Select
  94. Columns(col).Select
  95. Selection.Copy
  96. Sheets("Protocol").Select
  97. Columns(1).Select
  98. ActiveSheet.Paste
  99. End If
  100.  
  101.  
  102. End Function
  103.  
  104. Function GetColAddress(sheetName As String, target As String)
  105. Dim col As Range
  106.  
  107. Set col = Sheets(sheetName).Rows(1).Find(What:=target)
  108.  
  109. If col Is Nothing Then
  110. GetColAddress = False
  111. Else
  112. GetColAddress = col.Column
  113.  
  114. End If
  115.  
  116. End Function
  117.  
  118. Sub InsertColumns()
  119. Sheets("Protocol").Select
  120. Columns("B:B").Select
  121. 'Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  122. 'Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  123. 'Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  124. 'Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  125. 'Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  126. Range("B1").Select
  127. ActiveCell.FormulaR1C1 = "Common Points"
  128. Range("C1").Select
  129. ActiveCell.FormulaR1C1 = "Grade"
  130. Range("D1").Select
  131. ActiveCell.FormulaR1C1 = "Practical Points"
  132. Range("E1").Select
  133. ActiveCell.FormulaR1C1 = "Theoretical Points"
  134.  
  135. 'Rows(1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
  136.  
  137. 'Rows(1).EntireRow.Delete
  138. End Sub
  139.  
  140. Sub FormatHeaders(lastRow As Integer)
  141. Range("A1:E" & lastRow).Select
  142. Selection.ColumnWidth = 30
  143. Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  144. Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  145. With Selection.Borders(xlEdgeLeft)
  146. .LineStyle = xlContinuous
  147. .ColorIndex = 0
  148. .TintAndShade = 0
  149. .Weight = xlThin
  150. End With
  151. With Selection.Borders(xlEdgeTop)
  152. .LineStyle = xlContinuous
  153. .ColorIndex = 0
  154. .TintAndShade = 0
  155. .Weight = xlThin
  156. End With
  157. With Selection.Borders(xlEdgeBottom)
  158. .LineStyle = xlContinuous
  159. .ColorIndex = 0
  160. .TintAndShade = 0
  161. .Weight = xlThin
  162. End With
  163. With Selection.Borders(xlEdgeRight)
  164. .LineStyle = xlContinuous
  165. .ColorIndex = 0
  166. .TintAndShade = 0
  167. .Weight = xlThin
  168. End With
  169. With Selection.Borders(xlInsideVertical)
  170. .LineStyle = xlContinuous
  171. .ColorIndex = 0
  172. .TintAndShade = 0
  173. .Weight = xlThin
  174. End With
  175. With Selection.Borders(xlInsideHorizontal)
  176. .LineStyle = xlContinuous
  177. .ColorIndex = 0
  178. .TintAndShade = 0
  179. .Weight = xlThin
  180. End With
  181. With Selection
  182. .HorizontalAlignment = xlGeneral
  183. .VerticalAlignment = xlBottom
  184. .WrapText = True
  185. .Orientation = 0
  186. .AddIndent = False
  187. .IndentLevel = 0
  188. .ShrinkToFit = False
  189. .ReadingOrder = xlContext
  190. .MergeCells = False
  191. End With
  192. Range("A1:E1").Select
  193. With Selection.Font
  194. .Name = "Calibri"
  195. .Size = 14
  196. .Strikethrough = False
  197. .Superscript = False
  198. .Subscript = False
  199. .OutlineFont = False
  200. .Shadow = False
  201. .Underline = xlUnderlineStyleNone
  202. .ThemeColor = xlThemeColorLight1
  203. .TintAndShade = 0
  204. .ThemeFont = xlThemeFontMinor
  205. End With
  206. With Selection
  207. .HorizontalAlignment = xlGeneral
  208. .VerticalAlignment = xlCenter
  209. .WrapText = True
  210. .Orientation = 0
  211. .AddIndent = False
  212. .IndentLevel = 0
  213. .ShrinkToFit = False
  214. .ReadingOrder = xlContext
  215. .MergeCells = False
  216. End With
  217. With Selection
  218. .HorizontalAlignment = xlCenter
  219. .VerticalAlignment = xlCenter
  220. .WrapText = True
  221. .Orientation = 0
  222. .AddIndent = False
  223. .IndentLevel = 0
  224. .ShrinkToFit = False
  225. .ReadingOrder = xlContext
  226. .MergeCells = False
  227. End With
  228. With Selection.Interior
  229. .Pattern = xlSolid
  230. .PatternColorIndex = xlAutomatic
  231. .ThemeColor = xlThemeColorDark2
  232. .TintAndShade = 0
  233. .PatternTintAndShade = 0
  234. End With
  235. With ActiveWindow
  236. .SplitColumn = 0
  237. .SplitRow = 1
  238. End With
  239. ActiveWindow.FreezePanes = True
  240. End Sub
  241.  
  242.  
  243.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement