Basically I have two columns GrantNumber and IONames. I am trying to have a drop down menu (IONames) depending on another drop down menu (GrantNumber). So when a user puts his grantnumber and he goes to fill out IONames then only the ones that have to do with his GrantNumber need to show up in the IOName list or drop down menu.
I am getting a type mismatch error on:
If c.Value = ActiveSheet.Range("A2:A10000").Value Then 'selected GrantNumber
Any help is appreciated. Thanks
Sub SetupGrantNumber() 'run this on workbook open event
Dim rng As Range
Set rng = Worksheets("IOHealthcareLinkageTemplate").Range("A2:A10000") 'choose your cell(s) here
With rng.Validation
FRM = GetUniqueGrantNumbers()
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=FRM
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
Sub SetupIOName() 'run this sub on the change event of GrantNumber cell
Dim rng As Range
Set rng = Worksheets("IOHealthcareLinkageTemplate").Range("B2:B10000") 'choose your cell(s) here
With rng.Validation
FRM = GetIONames()
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=FRM
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
Function GetUniqueGrantNumbers() As String
Dim sOut As String
Dim v, c
Dim rngList As Range
Set rngList = Worksheets("IOs").Range("A2:A10000") 'edit the range where your GrantNumber list is stored
sOut = ""
For Each c In rngList
If InStr(1, sOut, c.Value & ",") = 0 Then 'check if the value is already in the upload list and add if not there
sOut = c.Value & "," & sOut
End If
Next c
'remove first ,
If sOut <> "" Then
sOut = Left(sOut, Len(sOut) - 1)
End If
GetUniqueGrantNumbers = sOut
End Function
Function GetIONames() As String
Dim sOut As String
Dim v, c
Dim rngSearch As Range
Set rngSearch = Worksheets("IOs").Range("C2:C10000") 'edit the range where your IOname list exists
sOut = ""
For Each c In rngSearch
If c.Value = ActiveSheet.Range("A2:A10000").Value Then 'selected GrantNumber
sOut = sOut & "," & ActiveSheet.Range("E" & c.Row).Value
End If
Next c
'remove first ,
If sOut <> "" Then
sOut = Mid(sOut, 2)
End If
GetIONames = sOut
End Function