Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. Private Sub ComboBoxDivision_Change()
  2.  
  3. Me.ComboBoxSpecsNumber = ""
  4. Me.ComboBoxSpecsName = ""
  5. Select Case Me.ComboBoxDivision
  6. Case "DIVISION 02 - EXISTING CONDITIONS"
  7. Me.ComboBoxSpecsNumber.RowSource = "D02_Number"
  8. Me.ComboBoxSpecsName.RowSource = "D02_Name"
  9.  
  10. Case "DIVISION 03 - CONCRETE"
  11. Me.ComboBoxSpecsNumber.RowSource = "D03_Number"
  12. Me.ComboBoxSpecsName.RowSource = "D03_Name"
  13.  
  14. Case "DIVISION 04 - MASONRY"
  15. Me.ComboBoxSpecsNumber.RowSource = "D04_Number"
  16. Me.ComboBoxSpecsName.RowSource = "D04_Name"
  17. End Select
  18. End Sub
  19.  
  20. Private Sub ComboBoxSpecsNumber_Change()
  21. Application.EnableEvents = False
  22. With ComboBoxSpecsNumber
  23. ComboBoxSpecsName.ListIndex = .ListIndex
  24. End With
  25. Application.EnableEvents = True
  26. End Sub
  27.  
  28. Private Sub ComboBoxSpecsName_Change()
  29. Application.EnableEvents = False
  30. With ComboBoxSpecsName
  31. ComboBoxSpecsNumber.ListIndex = .ListIndex
  32. End With
  33. Application.EnableEvents = True
  34. End Sub
  35.  
  36. Private Sub SubmitButton_Click()
  37. If Me.ComboBoxDivision.Value = "" Then
  38. MsgBox "Please select a Division.", vbExclamation, "Product_Information_Form"
  39. Me.ComboBoxDivision.SetFocus
  40. Exit Sub
  41. End If
  42. If Me.ComboBoxSpecsNumber.Value = "" Then
  43. MsgBox "Please select a Specs Number or Name.", vbExclamation, "Product_Information_Form"
  44. Me.ComboBoxSpecsNumber.SetFocus
  45. Exit Sub
  46. End If
  47. If Me.ComboBoxSpecsName.Value = "" Then
  48. MsgBox "Please select a Specs Name or Name.", vbExclamation, "Product_Information_Form"
  49. Me.ComboBoxSpecsName.SetFocus
  50. Exit Sub
  51. End If
  52.  
  53. Sub AddLink(c As Range, text As String)
  54. If Len(text) > 0 Then
  55. c.Formula = "=HYPERLINK(""" & text & """)"
  56. Else
  57. c.Value = ""
  58. End If
  59. End Sub
  60.  
  61. Dim RowCount As Long
  62. RowCount = Worksheets("FormData").Range("A1").CurrentRegion.Rows.Count
  63. With Worksheets("FormData").Range("A1")
  64. .Offset(RowCount, 0).Value = Me.ComboBoxDivision.Value
  65. .Offset(RowCount, 1).Value = Me.ComboBoxSpecsNumber.Value
  66. .Offset(RowCount, 2).Value = Me.ComboBoxSpecsName.Value
  67. AddLink .Offset(RowCount, 3), Me.TextBox_Website_Link.Value
  68. .Offset(RowCount, 4).Value = Format(Now, "yyyy.mm.dd hh:mm:ss")
  69. End With
  70.  
  71. Select Case Me.ComboBoxDivision
  72. Case "DIVISION 02 - EXISTING CONDITIONS"
  73. Dim LastRow As Long, ws As Worksheet
  74. Set ws = Sheets("Div-02")
  75. LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
  76. ws.Range("a" & LastRow).Value = Me.ComboBoxSpecsNumber.Value
  77. ws.Range("b" & LastRow).Value = Me.ComboBoxSpecsName.Value
  78. AddLink ws.Range("c" & LastRow), Me.TextBox_Website_Link.Value
  79.  
  80. Case "DIVISION 03 - CONCRETE"
  81. Set ws = Sheets("Div-03")
  82. LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
  83. ws.Range("a" & LastRow).Value = Me.ComboBoxSpecsNumber.Value
  84. ws.Range("b" & LastRow).Value = Me.ComboBoxSpecsName.Value
  85. AddLink ws.Range("c" & LastRow), Me.TextBox_Website_Link.Value
  86.  
  87. Case "DIVISION 04 - MASONRY"
  88. Set ws = Sheets("Div-04")
  89. LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
  90. ws.Range("a" & LastRow).Value = Me.ComboBoxSpecsNumber.Value
  91. ws.Range("b" & LastRow).Value = Me.ComboBoxSpecsName.Value
  92. AddLink ws.Range("c" & LastRow), Me.TextBox_Website_Link.Value
  93.  
  94.  
  95. End Select
  96.  
  97. Unload Product_Information_Form
  98. Start_Form.Show
  99.  
  100. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement