+ Reply to Thread
Results 1 to 10 of 10

If OR statement not executing properly

  1. #1
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    If OR statement not executing properly

    I cannot get this one to execute, please help me execute this statement. Its not displaying AAAAA if it compares the string B3000.

    Please Login or Register  to view this content.
    Any help would be appreciated.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: If OR statement not executing properly

    There is a comma in your string comparison "B3000:," hence it would not match to string "B3000" ? That could be the problem, otherwise, you should provide a more complete chunk of your code, there are 2 "If"'s right at the start of this snippet.

  3. #3
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: If OR statement not executing properly

    Sorry, for the If's
    There is just one IF and also the value which is to be displayed is as follows:
    Audit: B3000:,B3001:,.....
    Last edited by irfanparbatani; 08-22-2013 at 08:54 PM.

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: If OR statement not executing properly

    Show the part where you are setting the value to Audit ?

  5. #5
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: If OR statement not executing properly

    I feel that Audit contains whole data B3000:,B3001:,..... in this manner. So you need to split this into array and then check for the value.



    ________________________________________________________________________________________________
    if something has helped please click

    I have not failed. I've just found 10,000 ways that won't work.

    Thomas A. Edison

  6. #6
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: If OR statement not executing properly

    Hi
    Below is the audit code:
    Please Login or Register  to view this content.
    Thanks

  7. #7
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: If OR statement not executing properly

    So, let's say fldArray(UBound(fldArray)) contains only "B3000:,B3001:,",
    InStr(Audit, ":") would return 6.

    This line
    Please Login or Register  to view this content.
    would then translate into
    Please Login or Register  to view this content.
    which would be equals to "B3000". Hence comparison with "B3000:," would return a False

  8. #8
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: If OR statement not executing properly

    So how would we go about comparing it, cuz I get the output in a bulkfile(text file) and got to compare it before it writes to bulkfile.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: If OR statement not executing properly

    I suggest that you upload a dummy sample file, showing the data you are working with and what your expected answer would be. That way, members dont have to guess at what you are working with!
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: If OR statement not executing properly

    Quote Originally Posted by FDibbins View Post
    I suggest that you upload a dummy sample file, showing the data you are working with and what your expected answer would be. That way, members dont have to guess at what you are working with!
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

    I used Instr function to solve the above problem.

+ 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. [SOLVED] If statement not working properly.
    By jstawski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2013, 09:31 AM
  2. [SOLVED] VBA code running in wrong order and not executing properly
    By ollylondon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2012, 10:11 AM
  3. [SOLVED] Nested IF only executing first loop statement
    By kewcumber in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-22-2012, 03:51 PM
  4. IF Statement Not Working Properly
    By LaLaLand in forum Excel General
    Replies: 1
    Last Post: 12-12-2011, 05:40 PM
  5. [SOLVED] How to force Excel to complete one statement before executing othe
    By vrk1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-21-2005, 03:05 AM

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