Hello,
I need to develop an UDF for checking a cell value against several possible entries to check if the cell is equal to any of those values or not. I know how to do the check (I am thinking to assign the entries to a scripting dictionary and do a dic.exists function). But writing the function in a way that can accept multiple optional entries in not clear for me. The example in EXCEL functions is CONCATENATE( text1, [ text2, ... text_n ] ). My function for specific optional entries is as follow:
I want to make it dynamic for number of optional entries (As said like concatenate). and also if possible make the checking of entries automatic through a loop.
I was not able to do that as well
Thanks and regards,
M
I need to develop an UDF for checking a cell value against several possible entries to check if the cell is equal to any of those values or not. I know how to do the check (I am thinking to assign the entries to a scripting dictionary and do a dic.exists function). But writing the function in a way that can accept multiple optional entries in not clear for me. The example in EXCEL functions is CONCATENATE( text1, [ text2, ... text_n ] ). My function for specific optional entries is as follow:
Code:
Function IfAmong(TextToCheck As String, Text1 As String, Optional Text2 As String, Optional Text3 As String, Optional Text4 As String, Optional Text5 As String, Optional text6 As String) As Boolean Dim dd As New Scripting.Dictionary
dd.CompareMode = TextCompare
dd.Add Text1, dd.Count
If Text2 <> "" Then dd.Add Text2, dd.Count
If Text3 <> "" Then dd.Add Text3, dd.Count
If Text4 <> "" Then dd.Add Text4, dd.Count
If Text5 <> "" Then dd.Add Text5, dd.Count
If text6 <> "" Then dd.Add text6, dd.Count
IfAmong = dd.Exists(TextToCheck)
dd.RemoveAll
End Function
I want to make it dynamic for number of optional entries (As said like concatenate). and also if possible make the checking of entries automatic through a loop.
Code:
for i =2 to Ubound(text(i))
if text(i) <>"" then..........
next
I was not able to do that as well
Thanks and regards,
M