+ Reply to Thread
Results 1 to 4 of 4

Interesting Error With Instr Function

  1. #1
    Registered User
    Join Date
    12-30-2014
    Location
    USA
    MS-Off Ver
    MS Office 2010
    Posts
    1

    Interesting Error With Instr Function

    Hello All,

    I am having a weird error with "Instr". I have used it many times over, but never used it comparing two arrays against each other. Here is the deal. The two arrays listed below are both string arrays which have been trimmed, and upper cased. What is happening is when I set a breakpoint "LPosition" is never getting set....it is always 0 when in multiple cases it should be otherwise. When I find a case where it is a match I hover over "LPosition" and it is 0, but when I hover over InStr itself it shows that it indeed is working and matched at 1. When I try one that doesn't match I hover over InStr and it shows 0. The problem I am facing is why isn't it passing to the integer value. Any help would be appreciated. Thanks.



    Please Login or Register  to view this content.
    Last edited by alansidman; 12-08-2016 at 04:35 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,895

    Re: Interesting Error With Instr Function

    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
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Interesting Error With Instr Function

    I tried it (making up some value for merchname and merchmaster), but I did not readily recreate a scenario where Instr() did not return the correct value. We probably need to know what values are in merchname and merchmaster so that we can see what scenarios are causing the wrong value to be returned to Lposition.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Interesting Error With Instr Function

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    If posting code please use code tags, see here.

+ 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. Instr() function giving error: "Type mismatch"
    By arjun.majumdar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2013, 04:17 AM
  2. Replies: 4
    Last Post: 03-27-2013, 12:16 PM
  3. [SOLVED] InStr Function
    By msolari in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-18-2012, 01:52 PM
  4. [SOLVED] InStr Mismatch Error
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-04-2012, 09:39 AM
  5. Instr() function
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2011, 03:57 PM
  6. Instr runtime error
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-08-2011, 12:53 PM
  7. Instr Function
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2010, 03:58 PM
  8. [SOLVED] InStr Function
    By zoot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2006, 10:55 PM

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