View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ker_01 Ker_01 is offline
external usenet poster
 
Posts: 100
Default Instr syntax help

When faced with this scenario, I generally make an array of the matchable
values (easier to edit), then use application.match to compare the target
cell against the array to see if it is in the array. If it is, it will give
you the array position of the match. If not, it will return an error. Just
check to see if the returned value is an error, then 'do something
HTH,
Keith

(air code)
Deptnames = Array("Engineering", "Human Resources", "Maintenance")

FindDept = Application.Match(Sheet1.range("A1").value, DeptNames, False)
'use the worksheet match function to understand the parameters

If (IsError(FindDept)) Then
'wasn't a match
else
'was a match
endif

"u473" wrote in message
...
I cannot find in all my doc the proper syntax for Instr to replace my
long
If Proj = "51693" Or Proj = "61121" Or Proj = "52401" Or ..... Then
with something like
If Instr(Proj,"51693 61121 52401 61151 61191 52231 52401") Then
But what is the proper syntax with quotes, spaces & commas ?

...............
Range("A1").Select
Do
Proj = ActiveCell.Value
' Test the ActiveCell.Value against 10 allowed values
If Proj = "51693" Or Proj = "61121" Or Proj = "52401" Then
' Do something
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Row LastRow
Thank you for your help
Celeste