Advertisement
Guest User

gennaro

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. Option Explicit
  2. Public r As Long, c As Long, x As Long, Riga As Long, Trovato As Boolean, Marcat, Squadra, sPath, Rws
  3.  
  4. Sub eNo()
  5. Application.EnableEvents = False
  6. End Sub
  7. Sub eSi()
  8. Application.EnableEvents = True
  9. End Sub
  10. Sub sNo()
  11. Application.ScreenUpdating = False
  12. End Sub
  13. Sub sSI()
  14. Application.ScreenUpdating = True
  15. End Sub
  16.  
  17. Sub apri()
  18. UserForm1.Show vbModeless
  19. End Sub
  20.  
  21. Sub togli()
  22. Dim sh As Worksheet, r, r1, x, k, d1, d2
  23.  
  24. Set sh = Worksheets("Marcatori")
  25. sNo
  26. sh.Activate
  27. r = sh.Cells(1, 1).End(xlDown).Row
  28. r1 = 21
  29. sh.Range(Cells(2, 20), Cells(r, 23)).ClearContents
  30. sh.Range(Cells(2, 1), Cells(r, 3)).Copy sh.Cells(2, 20)
  31. For k = 2 To r1
  32. d1 = sh.Cells(k, 32)
  33. d2 = sh.Cells(k, 33)
  34. For x = 2 To r
  35. If d1 = sh.Cells(x, 20) Then sh.Cells(x, 23) = d2
  36. Next x
  37. Next k
  38.  
  39. For x = 2 To r 'elimina quelli con 1 solo gol
  40. If sh.Cells(x, 22) = 1 Then sh.Range(Cells(x, 21), Cells(x, 23)).ClearContents
  41. Next x
  42. 'Sheets("Reti").Select
  43. sSI
  44. End Sub
  45.  
  46.  
  47. Sub Cerca(dd, n) 'funzione di ricerca della riga/colonna corrispondente ad un dato
  48. On Error Resume Next
  49. Riga = 0
  50. Select Case n
  51. Case 1: Riga = WorksheetFunction.Match(dd, Marcat, 0) + 1 'cerca categoria in Indici
  52. Case 2: Riga = WorksheetFunction.Match(dd, Squadra, 0) + 1 'cerca subcategoria in indici
  53. End Select
  54. End Sub
  55.  
  56. Sub PulisciSquadre()
  57. Range("Squadre").ClearContents
  58. End Sub
  59.  
  60. Sub toglispazio()
  61. Dim r, x, n
  62.  
  63. n = 27
  64. r = Cells(Rows.Count, n).End(xlUp).Row
  65. For x = 1 To r
  66. Cells(x, n) = Replace(Cells(x, n), " ", "")
  67. Next x
  68. End Sub
  69.  
  70. Sub Aggiorna()
  71. Sheets("Classifica").Select
  72. ActiveSheet.Unprotect
  73. Range("B26:C45").Select
  74. Selection.Copy
  75. Range("B3").Select
  76. Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  77. :=False, Transpose:=False
  78. Range("B3:C22").Select
  79. Application.CutCopyMode = False
  80. Selection.Sort Key1:=Range("C3"), Order1:=xlDescending, Key2:=Range("B3") _
  81. , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
  82. False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
  83. :=xlSortNormal
  84. Range("B3").Select
  85. ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
  86. End Sub
  87.  
  88. Sub chiudi()
  89. Application.DisplayAlerts = False
  90. ActiveWorkbook.Save
  91. Application.Quit
  92. Application.DisplayAlerts = True
  93. End Sub
  94.  
  95. Sub Marcatori()
  96. Dim r As Long
  97. sNo
  98. Sheets("Marcatori").Select
  99. r = Cells(Rows.Count, 1).End(xlUp).Row
  100. Range("A1:C" & r).Select
  101. ActiveWorkbook.Worksheets("Marcatori").Sort.SortFields.Clear
  102. ActiveWorkbook.Worksheets("Marcatori").Sort.SortFields.Add Key:=Range( _
  103. "C2:C" & r), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
  104. xlSortNormal
  105. ActiveWorkbook.Worksheets("Marcatori").Sort.SortFields.Add Key:=Range( _
  106. "A2:A" & r), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
  107. xlSortNormal
  108. ActiveWorkbook.Worksheets("Marcatori").Sort.SortFields.Add Key:=Range( _
  109. "B2:B" & r), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
  110. xlSortNormal
  111. With ActiveWorkbook.Worksheets("Marcatori").Sort
  112. .SetRange Range("A1:C" & r)
  113. .Header = xlYes
  114. .MatchCase = False
  115. .Orientation = xlTopToBottom
  116. .SortMethod = xlPinYin
  117. .Apply
  118. End With
  119. End Sub
  120.  
  121. Sub ordina(d)
  122. If d = 1 Then Call OrdE2("Marcatori", 1, 1, 3, d, d + 1, 0)
  123. If d = 2 Then Call OrdE2("Marcatori", 1, 1, 3, d, d - 1, 0)
  124. If d = 3 Then Call OrdE2("Marcatori", 1, 1, 3, d, d - 1, 1)
  125. End Sub
  126.  
  127. Public Sub IniCbon(fg, rp, col, n, d) 'inizializza combobox + colonne
  128. sNo
  129. eNo
  130. Sheets(fg).Select
  131. If d = 0 Then Riga = Cells(Rows.Count, col).End(xlUp).Row
  132. If d = 1 Then Riga = Cells(rp, col).End(xlDown).Row
  133. If Cells(rp + 1, col) = "" Then Riga = rp + 1
  134. Rws = Range(Cells(rp + 1, col), Cells(Riga, col + n)).Address
  135. eSi
  136. sSI
  137. End Sub
  138.  
  139. Public Function TrovDat(fg, rp, col, Nome) 'trova dati in colonna
  140. Dim elenco As Range, Cl As Range
  141. Sheets(fg).Select
  142. Riga = Cells(Rows.Count, col).End(xlUp).Row
  143. If Cells(rp + 1, col) = "" Then Riga = rp + 1
  144. Set elenco = Range(Cells(rp + 1, col), Cells(Riga, col))
  145. Trovato = False
  146. If IsNumeric(Nome) Then Nome = Val(Nome)
  147. For Each Cl In elenco
  148. If Cl = Nome Then
  149. Riga = Cl.Row
  150. Trovato = True
  151. Exit For
  152. End If
  153. Next Cl
  154. End Function
  155.  
  156. Public Function OrdC(fg, rp, cop) 'ordina colonna
  157. Dim vert As Long
  158. Sheets(fg).Select
  159. If Cells(rp + 1, cop) = "" Then Exit Function
  160. vert = Cells(Rows.Count, cop).End(xlUp).Row
  161. Range(Cells(rp, cop), Cells(vert, cop)).Select
  162. Selection.Sort Key1:=Cells(rp + 1, cop), Order1:=xlAscending, Header:=xlYes, _
  163. OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  164. Cells(1, 1).Select
  165. End Function
  166.  
  167. Public Sub OrdE(fg, rp, cop, cof, coo, oo)
  168. Dim vert&
  169.  
  170. Sheets(fg).Select
  171. If Cells(rp + 1, cop) = "" Then Exit Sub
  172. vert = Cells(rp, cop).End(xlDown).Row
  173. Range(Cells(rp, cop), Cells(vert, cof)).Select
  174. If oo = 0 Then
  175. Selection.Sort Key1:=Cells(rp + 1, coo), Order1:=xlAscending, Header:=xlYes, _
  176. OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  177. End If
  178. If oo = 1 Then
  179. Selection.Sort Key1:=Cells(rp + 1, coo), Order1:=xlDescending, Header:=xlYes, _
  180. OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  181. End If
  182. Cells(1, 1).Select
  183. End Sub
  184.  
  185. Public Sub OrdE2(fg, rp, cop, cof, co1, co2, oo)
  186. Dim vert&
  187.  
  188. Sheets(fg).Select
  189. If Cells(rp + 1, cop) = "" Then Exit Sub
  190. vert = Cells(rp, cop).End(xlDown).Row
  191. Range(Cells(rp, cop), Cells(vert, cof)).Select
  192. If oo = 0 Then
  193. Selection.Sort Key1:=Cells(rp + 1, co1), Order1:=xlAscending, Key2:=Cells(rp + 1, co2) _
  194. , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
  195. False, Orientation:=xlTopToBottom
  196. End If
  197. If oo = 1 Then
  198. Selection.Sort Key1:=Cells(rp + 1, co1), Order1:=xlDescending, Key2:=Cells(rp + 1, co2) _
  199. , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
  200. False, Orientation:=xlTopToBottom
  201. End If
  202. Cells(1, 1).Select
  203. End Sub
  204.  
  205. Public Function iniz(dat) 'iniziale maiuscola
  206. Dim L0, L1, L2, L3
  207. L1 = Len(dat)
  208. For x = 1 To L1
  209. L0 = Mid(dat, x + 1, 1)
  210. L2 = Mid(dat, x, 1)
  211. If L2 = " " Then
  212. L2 = L2 + UCase(L0)
  213. x = x + 1
  214. End If
  215. If x = 1 Then L2 = UCase(L2)
  216. L3 = L3 + L2
  217. Next x
  218. iniz = L3
  219. End Function
  220.  
  221. Sub mettipunto()
  222. Dim x
  223.  
  224. For x = 2 To 108
  225. Cells(x, 15) = Cells(x, 17) & " " & Cells(x, 16) & "."
  226. Next x
  227.  
  228.  
  229. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement