Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9098943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:29:19+00:00 2026-06-17T00:29:19+00:00

If UBound(Filter(myArray, Sheets(i).Cells(1, j).Value, True)) = -1 Then ‘take action End if I used

  • 0
If UBound(Filter(myArray, Sheets(i).Cells(1, j).Value, True)) = -1 Then
 'take action
End if

I used this syntax to compare an element found in Cells(1, j) (e.g. “ally”) to all the elements of an array (e.g. “mally”, “kate”, “becks”), and to take action when no exact match is found.
Trouble is, based on this line of code it seems “ally” is considered as matching “mally” (probably because “ally” is a substring from “mally”), whereas I want “ally” to be recognised as distinct from “mally”.

Any help with the syntax as to achieve this? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:29:20+00:00Added an answer on June 17, 2026 at 12:29 am

    Filter will return any items that partially match. The work around suggested by Microsoft is to then search the filtered array for exact matches.

    Function FilterExactMatch(astrItems() As String, _
                              strSearch As String) As String()
    
       ' This function searches a string array for elements
       ' that exactly match the search string.
    
       Dim astrFilter()   As String
       Dim astrTemp()       As String
       Dim lngUpper         As Long
       Dim lngLower         As Long
       Dim lngIndex         As Long
       Dim lngCount         As Long
    
       ' Filter array for search string.
       astrFilter = Filter(astrItems, strSearch)
    
       ' Store upper and lower bounds of resulting array.
       lngUpper = UBound(astrFilter)
       lngLower = LBound(astrFilter)
    
       ' Resize temporary array to be same size.
       ReDim astrTemp(lngLower To lngUpper)
    
       ' Loop through each element in filtered array.
       For lngIndex = lngLower To lngUpper
          ' Check that element matches search string exactly.
          If astrFilter(lngIndex) = strSearch Then
             ' Store elements that match exactly in another array.
             astrTemp(lngCount) = strSearch
             lngCount = lngCount + 1
          End If
       Next lngIndex
    
       ' Resize array containing exact matches.
       ReDim Preserve astrTemp(lngLower To lngCount - 1)
    
       ' Return array containing exact matches.
       FilterExactMatch = astrTemp
    End Function
    

    This code is taken from http://msdn.microsoft.com/en-us/library/office/aa164525%28v=office.10%29.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In VBA for Excel: For i = 0 To UBound(artMaster) For j = i
I ran into unbound method error in python with this code: import random class
Passing an undimensioned array to the VB6's Ubound function will cause an error, so
I've got this 3 piece of code: For x = 0 To sections.Length -
Consider this code: function Foo(ds as OtherDLL.BaseObj) dim lngRowIndex as long dim lngColIndex as
I have this array in ASP CONST CARTPID = 0 CONST CARTPRICE = 1
Pls help me modify this code but I would like to keep it 90%
This problem is partly due to my lack of completely understanding scoping in python,
In the code below For i = LBound(arr) To UBound(arr) What is the point
Which are the equivalent of the following operators from VB.Net to C#? UBound() LBound()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.