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 8100039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:37:44+00:00 2026-06-05T22:37:44+00:00

Possible Duplicate: How to search for string in MS Access VBA array I am

  • 0

Possible Duplicate:
How to search for string in MS Access VBA array

I am currently working on an Excel macro, and I could not find a way to do like
if array.contains(mystring)

I wrote the following, and it gives me the message “Invaild Qualifier” and highlights the Mainfram right after If

Dim Mainfram(4) As String

Mainfram(0) = "apple"

Mainfram(1) = "pear"

Mainfram(2) = "orange"

Mainfram(3) = "fruit"

    For Each cel In Selection
        If Mainfram.Contains(cel.Text) Then
            Row(cel.Row).Style = "Accent1"
        End If
    Next cel

The selection is a column

Anyone help?

Hi, JP
I tried your suggestion, and it said Object required. And Highlightd the
If IsInArray(cell.Text, Mainfram) Then
Heres my full code

Sub changeRowColor()

Columns("B:B").Select

Dim cel As Excel.Range
Dim Mainfram(4) As String

Mainfram(0) = "apple"
Mainfram(1) = "pear"
Mainfram(2) = "orange"
Mainfram(3) = "Banana"

For Each cel In Selection
    If IsInArray(cell.Value, Mainfram) Then
        Rows(cel.Row).Style = "Accent1"
    End If
Next cel

End Sub

Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean

    IsInArray = (UBound(Filter(arr, stringToBeFound)) > -1)

End Function

Nevermind, I found that stupid Error…
Thank you anyways

  • 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-05T22:37:47+00:00Added an answer on June 5, 2026 at 10:37 pm

    Using the code from my answer to a very similar question:

    Sub DoSomething()
    Dim Mainfram(4) As String
    Dim cell As Excel.Range
    
    Mainfram(0) = "apple"
    Mainfram(1) = "pear"
    Mainfram(2) = "orange"
    Mainfram(3) = "fruit"
    
    For Each cell In Selection
      If IsInArray(cell.Value, MainFram) Then
        Row(cell.Row).Style = "Accent1"
      End If
    Next cell
    
    End Sub
    
    Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
      IsInArray = (UBound(Filter(arr, stringToBeFound)) > -1)
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: byte[] array pattern search I am trying to write a simple compression
Possible Duplicate: How to search for a string in files with Ant (make sure
Possible Duplicate: Search for string allowing for one mismatch in any location of the
Possible Duplicate: Oracle Search all tables all columns for string I'm looking for a
Possible Duplicate: Are there any Fuzzy Search or String Similarity Functions libraries written for
Possible Duplicate: Find sequence in IEnumerable<T> using Linq There is a string method: int
Possible Duplicate: byte[] array pattern search Let's say I have an array of bytes:
Possible Duplicate: Get query string values in JavaScript Parse query string in JavaScript http://www.example.org/search?q=example&another=test&again=more
Possible Duplicate: Regular Expression to find a string included between two characters, while EXCLUDING
Possible Duplicate: Search bar widget in android? I have to implement a Search Bar

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.