Here is a more appropriate example of what I want
The following code could be reduced to a loop from 1 to 10 like
for x = 1 to 10
strSearchX = "strSearch" & x
If strSearchX <> "" Then
If strSearchString = strSearchX Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
next x
if I could build a variable name using the base of the name and a counter
and then had some way of referencing the newly built variable.
Public Function inList(strSearchString As String, strSearch1 As String,
Optional strSearch2 As String, _
Optional strSearch3 As String, Optional strSearch4
As String, Optional strSearch5 As String, _
Optional strSearch6 As String, Optional strSearch7
As String, Optional strSearch8 As String, _
Optional strSearch9 As String, Optional strSearch10
As String) As Boolean
inList = False
'first search variable is required, no need to check to see if it is
present
If strSearchString = strSearch1 Then 'if the search string matches the
first parameter in the list then set inlist to true
inList = True
GoTo exitInlist 'you're done exit function
End If
If strSearch2 <> "" Then 'there is a second search variable
If strSearchString = strSearch2 Then 'it matches
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch3 <> "" Then
If strSearchString = strSearch3 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch4 <> "" Then
If strSearchString = strSearch4 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch5 <> "" Then
If strSearchString = strSearch5 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch6 <> "" Then
If strSearchString = strSearch6 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch7 <> "" Then
If strSearchString = strSearch7 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch8 <> "" Then
If strSearchString = strSearch8 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch9 <> "" Then
If strSearchString = strSearch9 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
If strSearch10 <> "" Then
If strSearchString = strSearch10 Then
inList = True
GoTo exitInlist 'you're done exit function
End If
End If
exitInlist:
End Function