When new users open the file they receive a "Compile error: Can't find project or library" error. Below is my VBA written to open up a worksheet when the field is selected and and also is a multi select drop down box data validation. Any help would be appreciated....
Also when looking at my script can you help me make the multi select appear in its own cell when selected?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'Selecting Multiple Values in a Drop Down Box
Dim rngDV As Range
Dim oldVal As String, newVal As String
Dim v As Variant, ws As Worksheet
On Error GoTo exitHandler
If Target.Count > 1 Or Target.Text = "" Then Exit Sub
If Not Intersect(Range("B36,B47"), Target) Is Nothing Then
Application.EnableEvents = False
newVal = Target.Text
Application.Undo
oldVal = Target.Text
Target.value = newVal
If oldVal <> "" Then
If oldVal = newVal Then
Target.value = ""
ElseIf InStr(1, oldVal, newVal) > 0 Then
If Right(oldVal, Len(newVal)) = newVal Then
Target.value = Left(oldVal, Len(oldVal) - Len(newVal) - 1)
Else
Target.value = Replace(oldVal, newVal & Chr(10), "")
End If
Else
Target.value = oldVal & Chr(10) & newVal
End If
End If
Application.ScreenUpdating = False
'Opening a Specific Worksheet Depending on What is Selected in the Incentive Type
For Each ws In Sheets(Array("Admin Fee", "Flat Fee", "Market Share", "Override"))
ws.Visible = False
Next ws
For Each v In Array("Admin Fee", "Business Development Bonus ", "Business Development Fee", _
"Flat Fee", "Global Business Development Bonus", "Maintenance Bonus", _
"Override", "Partnership Fee", "Transaction / Service Fee", _
"Select Incentive Type (s)")
If InStr(Target.value, v) Then
Select Case v
Case "Admin Fee", "Transaction / Service Fee"
Sheets("Admin Fee").Visible = True
'Sheets("Admin Fee").Select
Case "Business Development Bonus ", "Flat Fee", "Partnership Fee"
Sheets("Flat Fee").Visible = True
'Sheets("Flat Fee").Select
Case "Business Development Fee", "Override"
Sheets("Override").Visible = True
'Sheets("Override").Select
Case "Global Business Development Bonus", "Maintenance Bonus"
Sheets("Market Share").Visible = True
'Sheets("Market Share").Select
Case "Select Incentive Type (s)"
Case Else
End Select
End If
Next v
End If
exitHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical, "Worksheet_Change Error: " & Err.Number
End Sub
Thanks
Cindy
Also when looking at my script can you help me make the multi select appear in its own cell when selected?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'Selecting Multiple Values in a Drop Down Box
Dim rngDV As Range
Dim oldVal As String, newVal As String
Dim v As Variant, ws As Worksheet
On Error GoTo exitHandler
If Target.Count > 1 Or Target.Text = "" Then Exit Sub
If Not Intersect(Range("B36,B47"), Target) Is Nothing Then
Application.EnableEvents = False
newVal = Target.Text
Application.Undo
oldVal = Target.Text
Target.value = newVal
If oldVal <> "" Then
If oldVal = newVal Then
Target.value = ""
ElseIf InStr(1, oldVal, newVal) > 0 Then
If Right(oldVal, Len(newVal)) = newVal Then
Target.value = Left(oldVal, Len(oldVal) - Len(newVal) - 1)
Else
Target.value = Replace(oldVal, newVal & Chr(10), "")
End If
Else
Target.value = oldVal & Chr(10) & newVal
End If
End If
Application.ScreenUpdating = False
'Opening a Specific Worksheet Depending on What is Selected in the Incentive Type
For Each ws In Sheets(Array("Admin Fee", "Flat Fee", "Market Share", "Override"))
ws.Visible = False
Next ws
For Each v In Array("Admin Fee", "Business Development Bonus ", "Business Development Fee", _
"Flat Fee", "Global Business Development Bonus", "Maintenance Bonus", _
"Override", "Partnership Fee", "Transaction / Service Fee", _
"Select Incentive Type (s)")
If InStr(Target.value, v) Then
Select Case v
Case "Admin Fee", "Transaction / Service Fee"
Sheets("Admin Fee").Visible = True
'Sheets("Admin Fee").Select
Case "Business Development Bonus ", "Flat Fee", "Partnership Fee"
Sheets("Flat Fee").Visible = True
'Sheets("Flat Fee").Select
Case "Business Development Fee", "Override"
Sheets("Override").Visible = True
'Sheets("Override").Select
Case "Global Business Development Bonus", "Maintenance Bonus"
Sheets("Market Share").Visible = True
'Sheets("Market Share").Select
Case "Select Incentive Type (s)"
Case Else
End Select
End If
Next v
End If
exitHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical, "Worksheet_Change Error: " & Err.Number
End Sub
Thanks
Cindy