+ Reply to Thread
Results 1 to 4 of 4

If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work

  1. #1
    Registered User
    Join Date
    10-19-2016
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    8

    If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work

    Good Afternoon,

    I am writing a macro that tests for multiple conditions. I don't want to use an If, Else If, Else If, Else, End If when there are tons that I am programming.

    Below is a snippet of code:
    Please Login or Register  to view this content.
    When "BARRACUDA" is found in the file, the cell won't be highlighted, but if "Barracuda" is found, it will. Is there something I am not doing right?

    Thanks,
    Kevin Lombardi
    Last edited by alansidman; 10-19-2016 at 05:15 PM. Reason: code tags

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work

    Please Login or Register  to view this content.
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    10-19-2016
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    8

    Re: If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work

    Thank you. I just found my error. I had the incorrect cell reference in the middle of everything. I've been looking at code all day.

    Thanks for all your assistance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Highlight cells containing exact string value "our" and not "your" as well?
    By papazulu in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2016, 02:20 AM
  2. [SOLVED] Does not cosistantly find a text string using "InStr" function
    By Bobbbo in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-21-2016, 08:37 PM
  3. How to use InStr function to search for a text that starts with "CTF" and ends with "."?
    By yoursamrit2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-27-2014, 06:52 PM
  4. Replies: 1
    Last Post: 08-15-2014, 06:00 AM
  5. [SOLVED] Return's "Mismatch" error. Can Instr() be used on a column?
    By Newbiecode in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2014, 10:44 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. Instr() function giving error: "Type mismatch"
    By arjun.majumdar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2013, 04:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1