Microsoft Office Tutorials and References
In Depth Information
Try It
‘Declare and assign a String type variable for the element being evaluated.
Dim strVerify as String
strVerify = Worksheets(“Sheet1”).Range(“A1”).Value
‘Declare the Integer and Boolean data type variables.
Dim i as Integer, blnVerify as Boolean
‘Loop through each element starting with the first one (LBound)
‘and continue as necessary through to the last element (UBound).
‘If “Tom” is found, exit the loop and alert the user.
‘If “Tom” is not found, alert the user of that as well.
For i = LBound(myArray) To UBound(myArray)
If strVerify = myArray(i) Then
blnVerify = True
MsgBox “Yes! “ & myArray(i) & “ is in the array!”, , “Verified”
Worksheets(“Sheet2”).Visible = xlSheetVisible
Exit For
End If
Next i
If blnVerify = False Then _
MsgBox strVerify & “ is not in the array.”, , “No such animal.”
‘End the macro.
End Sub
To view the video that accompanies this lesson, please select Lesson 10, available
at the following website: .
Search JabSto ::

Custom Search