Guest User

Untitled

a guest
Jan 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. j = 1
  2.  
  3. For i = 5 To B.UsedRange.Columns.Count 'iterate through all the models'
  4.  
  5. If B.Cells(2, i).Value <> 0 Then 'case where there are versions of that model in build'
  6.  
  7. A.Cells(5, 2 * j).Value = B.Cells(1, i).Value 'print name of the model'
  8.  
  9. k = B.Cells(2, i).Value - B.Cells(3, i).Value + 1 'set k = to the total number of that model ever to be in build - the number of that model completed before the start of this year'
  10.  
  11. ReDim Ar1(k) As String 'set Ar1 to be a size such that it can contain all the models versions I wish to display'
  12.  
  13. For l = 0 To k - 1 'iterate through all of the model versions and add them to an array'
  14.  
  15. If B.Cells(3, i).Value + l < 10 Then 'version number is less than 10'
  16.  
  17. Ar1(l) = ("00" & CStr(B.Cells(3, i).Value + l))
  18.  
  19. ElseIf l > 9 And l < 100 Then 'version number is between 10 and 100
  20.  
  21. Ar1(l) = ("0" & CStr(B.Cells(3, i).Value + l))
  22.  
  23. Else 'version number is greater than 100'
  24.  
  25. Ar1(l) = CStr(B.Cells(3, i).Value + l)
  26.  
  27. End If
  28.  
  29. m = m + 1
  30.  
  31. Next l
  32.  
  33. With A.Cells(7, 2 * j).Validation 'selecting the cell to place the listbox in and creating it'
  34.  
  35. .Delete
  36. .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(Ar1, ",") 'adding the array containing the the version numbers'
  37. .InCellDropdown = True
  38. .InputTitle = A.Cells(7, 2 * j).Value
  39.  
  40. End With
  41.  
  42. Set Ran1 = A.Range(A.Cells(9, 2 * j), A.Cells(9, 2 * j)) 'picking the cell to create the button in'
  43.  
  44. Set Btn = A.Buttons.Add(Ran1.Left, Ran1.Top, Ran1.Width, Ran1.Height) 'creating the button'
  45.  
  46. With Btn
  47.  
  48. .OnAction = "loadboat"
  49. .Caption = "Edit"
  50. .Name = "Btn" & j
  51.  
  52. End With
  53.  
  54. j = j + 1
  55.  
  56. End If
  57.  
  58. Next i
Add Comment
Please, Sign In to add comment