Advertisement
HoCo_xXSamXx

VBA Code

Nov 4th, 2023 (edited)
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 3.85 KB | Source Code | 0 0
  1. '=========================Declarations=========================
  2.  
  3. Public MySelection As String
  4. Public IsFile As Boolean
  5.  
  6. Public Sub GetSelection()
  7.     MySelection = ActiveCell.Value
  8. End Sub
  9.  
  10. Public Sub LinkCheck()
  11.     'MySelection = ActiveCell.Value
  12.    If Len(ActiveCell.Value) > 0 And Left(ActiveCell.Value, 1) = "~" Then
  13.         MySelection = Mid(ActiveCell.Value, 2)
  14.     End If
  15. End Sub
  16.  
  17. Public Sub FileCheck()
  18.     IsFile = False
  19.     If ActiveCell.Value = "Open Me" Then
  20.         MySelection = ActiveCell.Offset(-1, 0).Value ' Offset(-1, 0) moves one row up from the active cell
  21.        Range("N8").Value = MySelection
  22.         Range("N9:N10000").Font.ColorIndex = xlAutomatic
  23.         IsFile = True
  24.     ElseIf ActiveCell.Value = "Open Me!" Then
  25.         MySelection = ActiveCell.Offset(-1, 0).Value ' Offset(-1, 0) moves one row up from the active cell
  26.        MySelection = Left(MySelection, Len(MySelection) - 1)
  27.         Range("N8").Value = MySelection
  28.         Range("N9:N10000").Font.ColorIndex = xlAutomatic
  29.         IsFile = True
  30.     End If
  31. End Sub
  32. Public Sub AutoFit()
  33.     Columns("B:L").EntireColumn.AutoFit
  34. End Sub
  35.  
  36. Public Sub FormatSelection()
  37.     Call GetSelection
  38.     Call LinkCheck
  39.     Call FileCheck
  40. End Sub
  41.  
  42. Sub refresh()
  43.     Range("N9:N10000").Font.ColorIndex = xlAutomatic
  44. End Sub
  45.  
  46. '=========================OPEN=========================
  47.  
  48. Sub Open0()
  49.     Call FormatSelection
  50.     If IsFile Then
  51.         Exit Sub
  52.     End If
  53.     Range("C8").Value = Range("B8") + MySelection
  54.     Call AutoFit
  55. End Sub
  56. Sub Open1()
  57.     Call FormatSelection
  58.     If IsFile Then
  59.         Exit Sub
  60.     End If
  61.     Range("D8").Value = Range("C8").Value + MySelection
  62.     Call AutoFit
  63. End Sub
  64. Sub Open2()
  65.     Call FormatSelection
  66.     If IsFile Then
  67.         Exit Sub
  68.     End If
  69.     Range("E8").Value = Range("D8").Value + Selection
  70.     Call AutoFit
  71. End Sub
  72. Sub Open3()
  73.     Call FormatSelection
  74.     If IsFile Then
  75.         Exit Sub
  76.     End If
  77.     Range("F8").Value = Range("E8").Value + Selection
  78.     Call AutoFit
  79. End Sub
  80. Sub Open4()
  81.     Call FormatSelection
  82.     If IsFile Then
  83.         Exit Sub
  84.     End If
  85.     Range("G8").Value = Range("F8").Value + Selection
  86.     Call AutoFit
  87. End Sub
  88. Sub Open5()
  89.     Call FormatSelection
  90.     If IsFile Then
  91.         Exit Sub
  92.     End If
  93.     Range("H8").Value = Range("G8").Value + Selection
  94.     Call AutoFit
  95. End Sub
  96. Sub Open6()
  97.     Call FormatSelection
  98.     If IsFile Then
  99.         Exit Sub
  100.     End If
  101.     Range("I8").Value = Range("H8").Value + Selection
  102.     Call AutoFit
  103. End Sub
  104. Sub Open7()
  105.     Call FormatSelection
  106.     If IsFile Then
  107.         Exit Sub
  108.     End If
  109.     Range("J8").Value = Range("I8").Value + Selection
  110.     Call AutoFit
  111. End Sub
  112. Sub Open8()
  113.     Call FormatSelection
  114.     If IsFile Then
  115.         Exit Sub
  116.     End If
  117.     Range("K8").Value = Range("J8").Value + Selection
  118.     Call AutoFit
  119. End Sub
  120. Sub Open9()
  121.     Call FormatSelection
  122.     If IsFile Then
  123.         Exit Sub
  124.     End If
  125.     Range("L8").Value = Range("K8").Value + Selection
  126.     Call AutoFit
  127. End Sub
  128. '=========================CLOSE=========================
  129. Sub Close1()
  130.     Range("C8").Value = 0
  131.     Call AutoFit
  132. End Sub
  133. Sub Close2()
  134.     Range("D8").Value = 0
  135.     Call AutoFit
  136. End Sub
  137. Sub Close3()
  138.     Range("E8").Value = 0
  139.     Call AutoFit
  140. End Sub
  141. Sub Close4()
  142.     Range("F8").Value = 0
  143.     Call AutoFit
  144. End Sub
  145. Sub Close5()
  146.     Range("G8").Value = 0
  147.     Call AutoFit
  148. End Sub
  149. Sub Close6()
  150.     Range("H8").Value = 0
  151.     Call AutoFit
  152. End Sub
  153. Sub Close7()
  154.     Range("I8").Value = 0
  155.     Call AutoFit
  156. End Sub
  157. Sub Close8()
  158.     Range("J8").Value = 0
  159.     Call AutoFit
  160. End Sub
  161. Sub Close9()
  162.     Range("K8").Value = 0
  163.     Call AutoFit
  164. End Sub
  165. Sub Close10()
  166.     Range("L8").Value = 0
  167.     Call AutoFit
  168. End Sub
  169. Sub CloseFile()
  170.     Range("N8").Value = 0
  171.     Rows("9:10000").EntireRow.AutoFit
  172. End Sub
  173.  
  174.  
  175.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement